From b8628f0bcfcba99397aba19a0f65ebcced9aa359 Mon Sep 17 00:00:00 2001 From: crStiv Date: Sun, 5 Jan 2025 01:48:47 +0100 Subject: [PATCH] Update types_test.go --- signer/core/apitypes/types_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/signer/core/apitypes/types_test.go b/signer/core/apitypes/types_test.go index 22bbeba19e..11a28f04e2 100644 --- a/signer/core/apitypes/types_test.go +++ b/signer/core/apitypes/types_test.go @@ -25,6 +25,7 @@ import ( "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto/kzg4844" "github.com/holiman/uint256" + "github.com/ethereum/go-ethereum/common/hexutil" ) func TestIsPrimitive(t *testing.T) { @@ -233,3 +234,27 @@ func TestType_TypeName(t *testing.T) { } } } + +func TestEncodeNestedBytesArray(t *testing.T) { + typedData := TypedData{ + Types: Types{ + "EIP712Domain": []Type{}, + "Test": []Type{ + {Name: "data", Type: "bytes[]"}, + }, + }, + PrimaryType: "Test", + Domain: TypedDataDomain{}, + Message: map[string]interface{}{ + "data": []interface{}{ + hexutil.MustDecode("0x1234"), + hexutil.MustDecode("0x5678"), + }, + }, + } + + _, err := typedData.HashStruct(typedData.PrimaryType, typedData.Message) + if err != nil { + t.Errorf("Failed to hash struct with nested bytes array: %v", err) + } +}