prysm-pulse/sharding/collation_test.go
Raul Jordan fc1fb315bc sharding: replace StringToHash and StringToAddress deprecated methods
Former-commit-id: ff398a7f1b661f52735aceed6cd2d52ede02fc49 [formerly 42fbcc22fc08bf6d14b7a783adc9aecfabc83c60]
Former-commit-id: de4aa4af63aa42bced0c592b6e8afec404361022
2018-05-16 16:51:45 -04:00

45 lines
1.3 KiB
Go

package sharding
import (
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
func TestCollation_Transactions(t *testing.T) {
header := NewCollationHeader(big.NewInt(1), nil, big.NewInt(1), nil, []byte{})
body := []byte{}
transactions := []*types.Transaction{
makeTxWithGasLimit(0),
makeTxWithGasLimit(1),
makeTxWithGasLimit(2),
makeTxWithGasLimit(3),
}
collation := NewCollation(header, body, transactions)
for i, tx := range collation.Transactions() {
if tx.Hash().String() != transactions[i].Hash().String() {
t.Errorf("initialized collation struct does not contain correct transactions")
}
}
}
func TestCollation_ProposerAddress(t *testing.T) {
proposerAddr := common.BytesToAddress([]byte("proposer"))
header := NewCollationHeader(big.NewInt(1), nil, big.NewInt(1), &proposerAddr, []byte{})
body := []byte{}
collation := NewCollation(header, body, nil)
if collation.ProposerAddress().String() != proposerAddr.String() {
t.Errorf("initialized collation does not contain correct proposer address")
}
}
func makeTxWithGasLimit(gl uint64) *types.Transaction {
return types.NewTransaction(0 /*nonce*/, common.HexToAddress("0x0") /*to*/, nil /*amount*/, gl, nil /*gasPrice*/, nil /*data*/)
}