Update types_test.go

This commit is contained in:
crStiv 2025-01-05 01:48:47 +01:00 committed by GitHub
parent b2457f32ed
commit b8628f0bcf
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 25 additions and 0 deletions

View File

@ -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)
}
}