github.com/bytom/bytom@v1.1.2-0.20221014091027-bbcba3df6075/protocol/bc/tx_test.go (about)

     1  package bc
     2  
     3  import (
     4  	"testing"
     5  )
     6  
     7  func TestSigHash(t *testing.T) {
     8  	cases := []struct {
     9  		tx       *Tx
    10  		wantHash string
    11  	}{
    12  		{
    13  			tx: &Tx{
    14  				ID: Hash{V0: 13464118406972499748, V1: 5083224803004805715, V2: 16263625389659454272, V3: 9428032044180324575},
    15  				InputIDs: []Hash{
    16  					{V0: 14760873410800997144, V1: 1698395500822741684, V2: 5965908492734661392, V3: 9445539829830863994},
    17  				},
    18  			},
    19  			wantHash: "17dfad182df66212f6f694d774285e5989c5d9d1add6d5ce51a5930dbef360d8",
    20  		},
    21  		{
    22  			tx: &Tx{
    23  				ID: Hash{V0: 17091584763764411831, V1: 2315724244669489432, V2: 4322938623810388342, V3: 11167378497724951792},
    24  				InputIDs: []Hash{
    25  					{V0: 6970879411704044573, V1: 10086395903308657573, V2: 10107608596190358115, V3: 8645856247221333302},
    26  				},
    27  			},
    28  			wantHash: "f650ba3a58f90d3a2215f6c50a692a86c621b7968bb2a059a4c8e0c819770430",
    29  		},
    30  	}
    31  
    32  	for _, c := range cases {
    33  		gotHash := c.tx.SigHash(0)
    34  		if gotHash.String() != c.wantHash {
    35  			t.Errorf("got hash:%s, want hash:%s", gotHash.String(), c.wantHash)
    36  		}
    37  	}
    38  }