diff --git a/sharding/transactions.go b/sharding/transactions.go index 77a1c0191..14e8731eb 100644 --- a/sharding/transactions.go +++ b/sharding/transactions.go @@ -33,7 +33,7 @@ type txdata struct { // Sharding specific fields // TODO: Figure out exact format of accesslist. array of arrays of addr + prefixes? - AccessList []*common.Address `json:"accessList" gencodec:"required"` + AccessList []common.Address `json:"accessList" gencodec:"required"` // This is only used when marshaling to JSON. Hash *common.Hash `json:"hash" rlp:"-"` @@ -49,15 +49,15 @@ type txdataMarshaling struct { ShardID hexutil.Uint64 } -func NewShardingTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accessList []*common.Address) *ShardingTransaction { +func NewShardingTransaction(nonce uint64, to common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accessList []common.Address) *ShardingTransaction { return newShardingTransaction(nonce, &to, amount, gasLimit, gasPrice, data, accessList) } -func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accessList []*common.Address) *ShardingTransaction { +func NewContractCreation(nonce uint64, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accessList []common.Address) *ShardingTransaction { return newShardingTransaction(nonce, nil, amount, gasLimit, gasPrice, data, accessList) } -func newShardingTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accessList []*common.Address) *ShardingTransaction { +func newShardingTransaction(nonce uint64, to *common.Address, amount *big.Int, gasLimit uint64, gasPrice *big.Int, data []byte, accessList []common.Address) *ShardingTransaction { if len(data) > 0 { data = common.CopyBytes(data) } diff --git a/sharding/transactions_test.go b/sharding/transactions_test.go index dc7b45594..3c53d9476 100644 --- a/sharding/transactions_test.go +++ b/sharding/transactions_test.go @@ -5,11 +5,33 @@ import ( //"fmt" //"math/rand" //"os" + "github.com/ethereum/go-ethereum/common" + "math/big" "testing" ) +var ( + txSimple = NewShardingTransaction( + 0, + common.HexToAddress("095e7baea6a6c7c4c2dfeb977efac326af552d87"), + // amount + big.NewInt(10), + // gasLimit + 1000000, + // gasPrice + big.NewInt(1), + // data + common.FromHex("hello world this is the data"), + // access list + []common.Address{common.HexToAddress("032e7baea6a6c7c4c2dfe98392932326af552d87"), common.HexToAddress("083e7baea6a6c7c4c2dfeb97710293843f552d87")}, + ) +) + func TestCreation(t *testing.T) { - if 1 != 2 { - t.Fatalf("Values are not equal") + if txSimple.ChainID().Cmp(big.NewInt(1)) != 0 { + t.Fatalf("ChainID invalid") + } + if txSimple.ShardID().Cmp(big.NewInt(1)) != 0 { + t.Fatalf("ShardID invalid") } }