github.com/MetalBlockchain/metalgo@v1.11.9/tests/fixture/subnet/xsvm.go (about) 1 // Copyright (C) 2019-2024, Ava Labs, Inc. All rights reserved. 2 // See the file LICENSE for licensing terms. 3 4 package subnet 5 6 import ( 7 "math" 8 "time" 9 10 "github.com/MetalBlockchain/metalgo/tests/fixture/tmpnet" 11 "github.com/MetalBlockchain/metalgo/utils/constants" 12 "github.com/MetalBlockchain/metalgo/utils/crypto/secp256k1" 13 "github.com/MetalBlockchain/metalgo/vms/example/xsvm/genesis" 14 ) 15 16 func NewXSVMOrPanic(name string, key *secp256k1.PrivateKey, nodes ...*tmpnet.Node) *tmpnet.Subnet { 17 if len(nodes) == 0 { 18 panic("a subnet must be validated by at least one node") 19 } 20 21 genesisBytes, err := genesis.Codec.Marshal(genesis.CodecVersion, &genesis.Genesis{ 22 Timestamp: time.Now().Unix(), 23 Allocations: []genesis.Allocation{ 24 { 25 Address: key.Address(), 26 Balance: math.MaxUint64, 27 }, 28 }, 29 }) 30 if err != nil { 31 panic(err) 32 } 33 34 return &tmpnet.Subnet{ 35 Name: name, 36 Chains: []*tmpnet.Chain{ 37 { 38 VMID: constants.XSVMID, 39 Genesis: genesisBytes, 40 PreFundedKey: key, 41 }, 42 }, 43 ValidatorIDs: tmpnet.NodesToIDs(nodes...), 44 } 45 }