move recursive bytes type encoding test to signed_data_test.go

This commit is contained in:
Jared Wasinger 2025-02-19 19:37:13 -08:00
parent a38f10311d
commit e5346904e7
2 changed files with 46 additions and 60 deletions

View file

@ -1,60 +0,0 @@
package core
import (
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/signer/core/apitypes"
"testing"
)
var typesStandard = apitypes.Types{
"EIP712Domain": {
{
Name: "name",
Type: "string",
},
{
Name: "version",
Type: "string",
},
{
Name: "chainId",
Type: "uint256",
},
{
Name: "verifyingContract",
Type: "address",
},
},
"Val": {
{
Name: "field",
Type: "bytes[][]",
},
},
}
var messageStandard = map[string]interface{}{
"field": [][][]byte{{{1}, {2}}, {{3}, {4}}},
}
var domainStandard = apitypes.TypedDataDomain{
Name: "Recursive Bytes",
Version: "1",
ChainId: math.NewHexOrDecimal256(1),
VerifyingContract: "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC",
Salt: "",
}
var typedData = apitypes.TypedData{
Types: typesStandard,
PrimaryType: "Val",
Domain: domainStandard,
Message: messageStandard,
}
func TestEncodeDataRecursiveBytes(t *testing.T) {
_, err := typedData.EncodeData(typedData.PrimaryType, typedData.Message, 0)
if err != nil {
t.Fatalf("got err %v", err)
}
}

View file

@ -1014,3 +1014,49 @@ func TestComplexTypedDataWithLowercaseReftype(t *testing.T) {
t.Fatalf("Error, got %x, wanted %x", sighash, expSigHash) t.Fatalf("Error, got %x, wanted %x", sighash, expSigHash)
} }
} }
var recursiveBytesTypesStandard = apitypes.Types{
"EIP712Domain": {
{
Name: "name",
Type: "string",
},
{
Name: "version",
Type: "string",
},
{
Name: "chainId",
Type: "uint256",
},
{
Name: "verifyingContract",
Type: "address",
},
},
"Val": {
{
Name: "field",
Type: "bytes[][]",
},
},
}
var recursiveBytesMessageStandard = map[string]interface{}{
"field": [][][]byte{{{1}, {2}}, {{3}, {4}}},
}
var recursiveBytesTypedData = apitypes.TypedData{
Types: recursiveBytesTypesStandard,
PrimaryType: "Val",
Domain: domainStandard,
Message: recursiveBytesMessageStandard,
}
func TestEncodeDataRecursiveBytes(t *testing.T) {
typedData := recursiveBytesTypedData
_, err := typedData.EncodeData(typedData.PrimaryType, typedData.Message, 0)
if err != nil {
t.Fatalf("got err %v", err)
}
}