mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-17 01:13:45 +00:00
move recursive bytes type encoding test to signed_data_test.go
This commit is contained in:
parent
a38f10311d
commit
e5346904e7
2 changed files with 46 additions and 60 deletions
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
@ -1014,3 +1014,49 @@ func TestComplexTypedDataWithLowercaseReftype(t *testing.T) {
|
|||
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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue