@@ -49,31 +49,36 @@ func TestEncodingMatchesContractDecoding(t *testing.T) {
4949
5050 // Test AddPieces encoding
5151 t .Run ("AddPieces" , func (t * testing.T ) {
52+ nonce := big .NewInt (7 )
5253 signature := & AuthSignature {V : 27 , R : [32 ]byte {1 }, S : [32 ]byte {2 }}
5354 metadata := [][]MetadataEntry {
5455 {{Key : "piece1" , Value : "value1" }},
5556 {{Key : "piece2" , Value : "value2" }},
5657 }
5758
58- encoded , err := encoder .EncodeAddPiecesExtraData (signature , metadata )
59+ encoded , err := encoder .EncodeAddPiecesExtraData (nonce , signature , metadata )
5960 require .NoError (t , err )
6061
6162 // Decode using the contract's expected format
6263 arguments := abi.Arguments {
63- {Type : bytesType },
64+ {Type : uint256Type },
6465 {Type : stringDoubleArrayType },
6566 {Type : stringDoubleArrayType },
67+ {Type : bytesType },
6668 }
6769
6870 unpacked , err := arguments .Unpack (encoded )
6971 require .NoError (t , err )
70- require .Len (t , unpacked , 3 )
72+ require .Len (t , unpacked , 4 )
73+
74+ // Verify nonce
75+ require .Equal (t , nonce , unpacked [0 ].(* big.Int ))
7176
7277 // Verify signature
73- require .NotEmpty (t , unpacked [0 ].([]byte ))
78+ require .NotEmpty (t , unpacked [3 ].([]byte ))
7479
7580 // Verify metadata keys
76- keys := unpacked [1 ].([][]string )
81+ keys := unpacked [1 ].([][]string ) // wt operations preserve order
7782 require .Len (t , keys , 2 )
7883 require .Equal (t , []string {"piece1" }, keys [0 ])
7984 require .Equal (t , []string {"piece2" }, keys [1 ])
@@ -188,4 +193,4 @@ func TestEncodingBreakageDetection(t *testing.T) {
188193 _ , exists := serviceContractABI .Methods [methodName ]
189194 require .True (t , exists , "Required method %s must exist in contract ABI" , methodName )
190195 }
191- }
196+ }
0 commit comments