Merge pull request #105 from rauljordan/tests-fix

Fixing #104 By Removing Outdated Tests

Former-commit-id: c7961ce97d0539965083649275eb8785a7aa859d [formerly 18910123893b2c53c93f4d642896bee32f65f233]
Former-commit-id: 61a545015294a2f9c91b70366ac2855a394d6e5c
This commit is contained in:
Preston Van Loon 2018-05-03 18:13:45 -04:00 committed by GitHub
commit f192d00165

View File

@ -1,14 +1,15 @@
package sharding
import (
"math"
"math/big"
"testing"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
)
// TODO: this test needs to change as we will be serializing tx's into blobs
// within the collation body instead.
func TestCollation_AddTransactions(t *testing.T) {
tests := []struct {
transactions []*types.Transaction
@ -42,40 +43,6 @@ func TestCollation_AddTransactions(t *testing.T) {
}
}
func TestCollation_GasUsed(t *testing.T) {
tests := []struct {
transactions []*types.Transaction
gasUsed *big.Int
}{
{
transactions: []*types.Transaction{
makeTxWithGasLimit(100),
makeTxWithGasLimit(100000),
makeTxWithGasLimit(899900),
},
gasUsed: big.NewInt(1000000),
}, {
transactions: []*types.Transaction{},
gasUsed: big.NewInt(0),
},
{
transactions: []*types.Transaction{
makeTxWithGasLimit(math.MaxUint64),
makeTxWithGasLimit(9001),
makeTxWithGasLimit(math.MaxUint64),
},
gasUsed: big.NewInt(0).SetUint64(math.MaxUint64),
},
}
for _, tt := range tests {
got := (&Collation{transactions: tt.transactions}).GasUsed()
if tt.gasUsed.Cmp(got) != 0 {
t.Errorf("Returned unexpected gasUsed. Got=%v, wanted=%v", got, tt.gasUsed)
}
}
}
func makeTxWithGasLimit(gl uint64) *types.Transaction {
return types.NewTransaction(0 /*nonce*/, common.HexToAddress("0x0") /*to*/, nil /*amount*/, gl, nil /*gasPrice*/, nil /*data*/)
}