mirror of https://github.com/poanetwork/gecko.git
168 lines
5.6 KiB
Go
168 lines
5.6 KiB
Go
// (c) 2019-2020, Ava Labs, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package avm
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/ava-labs/gecko/utils/formatting"
|
|
)
|
|
|
|
func TestBuildGenesis(t *testing.T) {
|
|
ss := StaticService{}
|
|
|
|
args := BuildGenesisArgs{GenesisData: map[string]AssetDefinition{
|
|
"asset1": AssetDefinition{
|
|
Name: "myFixedCapAsset",
|
|
Symbol: "MFCA",
|
|
Denomination: 8,
|
|
InitialState: map[string][]interface{}{
|
|
"fixedCap": []interface{}{
|
|
Holder{
|
|
Amount: 100000,
|
|
Address: "A9bTQjfYGBFK3JPRJqF2eh3JYL7cHocvy",
|
|
},
|
|
Holder{
|
|
Amount: 100000,
|
|
Address: "6mxBGnjGDCKgkVe7yfrmvMA7xE7qCv3vv",
|
|
},
|
|
Holder{
|
|
Amount: 50000,
|
|
Address: "6ncQ19Q2U4MamkCYzshhD8XFjfwAWFzTa",
|
|
},
|
|
Holder{
|
|
Amount: 50000,
|
|
Address: "Jz9ayEDt7dx9hDx45aXALujWmL9ZUuqe7",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
"asset2": AssetDefinition{
|
|
Name: "myVarCapAsset",
|
|
Symbol: "MVCA",
|
|
InitialState: map[string][]interface{}{
|
|
"variableCap": []interface{}{
|
|
Owners{
|
|
Threshold: 1,
|
|
Minters: []string{
|
|
"A9bTQjfYGBFK3JPRJqF2eh3JYL7cHocvy",
|
|
"6mxBGnjGDCKgkVe7yfrmvMA7xE7qCv3vv",
|
|
},
|
|
},
|
|
Owners{
|
|
Threshold: 2,
|
|
Minters: []string{
|
|
"6ncQ19Q2U4MamkCYzshhD8XFjfwAWFzTa",
|
|
"Jz9ayEDt7dx9hDx45aXALujWmL9ZUuqe7",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
"asset3": AssetDefinition{
|
|
Name: "myOtherVarCapAsset",
|
|
InitialState: map[string][]interface{}{
|
|
"variableCap": []interface{}{
|
|
Owners{
|
|
Threshold: 1,
|
|
Minters: []string{
|
|
"A9bTQjfYGBFK3JPRJqF2eh3JYL7cHocvy",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}}
|
|
reply := BuildGenesisReply{}
|
|
err := ss.BuildGenesis(nil, &args, &reply)
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
|
|
expected := formatting.CB58{Bytes: []byte{
|
|
0x00, 0x00, 0x00, 0x03, 0x00, 0x06, 0x61, 0x73,
|
|
0x73, 0x65, 0x74, 0x31, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x0f, 0x6d, 0x79, 0x46, 0x69, 0x78, 0x65,
|
|
0x64, 0x43, 0x61, 0x70, 0x41, 0x73, 0x73, 0x65,
|
|
0x74, 0x00, 0x04, 0x4d, 0x46, 0x43, 0x41, 0x08,
|
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x06,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x50,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
|
|
0x3f, 0x78, 0xe5, 0x10, 0xdf, 0x62, 0xbc, 0x48,
|
|
0xb0, 0x82, 0x9e, 0xc0, 0x6d, 0x6a, 0x6b, 0x98,
|
|
0x06, 0x2d, 0x69, 0x53, 0x00, 0x00, 0x00, 0x06,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc3, 0x50,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
|
|
0xc5, 0x49, 0x03, 0xde, 0x51, 0x77, 0xa1, 0x6f,
|
|
0x78, 0x11, 0x77, 0x1e, 0xf2, 0xf4, 0x65, 0x9d,
|
|
0x9e, 0x86, 0x46, 0x71, 0x00, 0x00, 0x00, 0x06,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x86, 0xa0,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
|
|
0x3f, 0x58, 0xfd, 0xa2, 0xe9, 0xea, 0x8d, 0x9e,
|
|
0x4b, 0x18, 0x18, 0x32, 0xa0, 0x7b, 0x26, 0xda,
|
|
0xe2, 0x86, 0xf2, 0xcb, 0x00, 0x00, 0x00, 0x06,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x86, 0xa0,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01,
|
|
0x64, 0x59, 0x38, 0xbb, 0x7a, 0xe2, 0x19, 0x32,
|
|
0x70, 0xe6, 0xff, 0xef, 0x00, 0x9e, 0x36, 0x64,
|
|
0xd1, 0x1e, 0x07, 0xc1, 0x00, 0x06, 0x61, 0x73,
|
|
0x73, 0x65, 0x74, 0x32, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x0d, 0x6d, 0x79, 0x56, 0x61, 0x72, 0x43,
|
|
0x61, 0x70, 0x41, 0x73, 0x73, 0x65, 0x74, 0x00,
|
|
0x04, 0x4d, 0x56, 0x43, 0x41, 0x00, 0x00, 0x00,
|
|
0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x02, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00,
|
|
0x00, 0x01, 0x00, 0x00, 0x00, 0x02, 0x3f, 0x58,
|
|
0xfd, 0xa2, 0xe9, 0xea, 0x8d, 0x9e, 0x4b, 0x18,
|
|
0x18, 0x32, 0xa0, 0x7b, 0x26, 0xda, 0xe2, 0x86,
|
|
0xf2, 0xcb, 0x64, 0x59, 0x38, 0xbb, 0x7a, 0xe2,
|
|
0x19, 0x32, 0x70, 0xe6, 0xff, 0xef, 0x00, 0x9e,
|
|
0x36, 0x64, 0xd1, 0x1e, 0x07, 0xc1, 0x00, 0x00,
|
|
0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00,
|
|
0x00, 0x02, 0x3f, 0x78, 0xe5, 0x10, 0xdf, 0x62,
|
|
0xbc, 0x48, 0xb0, 0x82, 0x9e, 0xc0, 0x6d, 0x6a,
|
|
0x6b, 0x98, 0x06, 0x2d, 0x69, 0x53, 0xc5, 0x49,
|
|
0x03, 0xde, 0x51, 0x77, 0xa1, 0x6f, 0x78, 0x11,
|
|
0x77, 0x1e, 0xf2, 0xf4, 0x65, 0x9d, 0x9e, 0x86,
|
|
0x46, 0x71, 0x00, 0x06, 0x61, 0x73, 0x73, 0x65,
|
|
0x74, 0x33, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x12,
|
|
0x6d, 0x79, 0x4f, 0x74, 0x68, 0x65, 0x72, 0x56,
|
|
0x61, 0x72, 0x43, 0x61, 0x70, 0x41, 0x73, 0x73,
|
|
0x65, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
|
|
0x01, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00,
|
|
0x01, 0x00, 0x00, 0x00, 0x01, 0x64, 0x59, 0x38,
|
|
0xbb, 0x7a, 0xe2, 0x19, 0x32, 0x70, 0xe6, 0xff,
|
|
0xef, 0x00, 0x9e, 0x36, 0x64, 0xd1, 0x1e, 0x07,
|
|
0xc1,
|
|
}}
|
|
|
|
if result := reply.Bytes.String(); result != expected.String() {
|
|
t.Fatalf("Create genesis returned:\n%s\nExpected:\n%s",
|
|
formatting.DumpBytes{Bytes: reply.Bytes.Bytes},
|
|
formatting.DumpBytes{Bytes: expected.Bytes},
|
|
)
|
|
}
|
|
}
|