File tree 1 file changed +43
-0
lines changed
1 file changed +43
-0
lines changed Original file line number Diff line number Diff line change
1
+ // Copyright 2025 Blink Labs Software
2
+ //
3
+ // Use of this source code is governed by an MIT-style
4
+ // license that can be found in the LICENSE file or at
5
+ // https://opensource.org/licenses/MIT.
6
+
7
+ package handshake_test
8
+
9
+ import (
10
+ "bytes"
11
+ "encoding/hex"
12
+ "testing"
13
+
14
+ "github.com/blinklabs-io/cdnsd/internal/handshake"
15
+ )
16
+
17
+ func TestTransactionHash (t * testing.T ) {
18
+ // From TX 1881afbe757f9d433144edf49e29c7f6bbfdbc1941d06792dc5ee13020d63570 on mainnet
19
+ testTxBytes := decodeHex ("00000000010000000000000000000000000000000000000000000000000000000000000000ffffffff3b2cf8140134369b3b00000000001498c8297a67eb81ec36253828b5621a601ba2328a0000a62204000306566961425443087c524fd539e1eab8080000000000000000" )
20
+ expectedHash := "1881afbe757f9d433144edf49e29c7f6bbfdbc1941d06792dc5ee13020d63570"
21
+ expectedWitnessHash := "d36b1e9861dd504629b053d14d9801b295667a4c7002c9d2836be502bfdb3b3a"
22
+ br := bytes .NewReader (testTxBytes )
23
+ tmpTx , err := handshake .NewTransactionFromReader (br )
24
+ if err != nil {
25
+ t .Fatalf ("unexpected error decoding transaction: %s" , err )
26
+ }
27
+ tmpTxHash := hex .EncodeToString (tmpTx .Hash ())
28
+ if tmpTxHash != expectedHash {
29
+ t .Fatalf (
30
+ "did not get expected TX hash: got %s, wanted %s" ,
31
+ tmpTxHash ,
32
+ expectedHash ,
33
+ )
34
+ }
35
+ tmpTxWitnessHash := hex .EncodeToString (tmpTx .WitnessHash ())
36
+ if tmpTxWitnessHash != expectedWitnessHash {
37
+ t .Fatalf (
38
+ "did not get expected TX witness hash: got %s, wanted %s" ,
39
+ tmpTxWitnessHash ,
40
+ expectedWitnessHash ,
41
+ )
42
+ }
43
+ }
You can’t perform that action at this time.
0 commit comments