diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/block_test_util.go | 11 | ||||
-rw-r--r-- | tests/transaction_test_util.go | 45 |
2 files changed, 27 insertions, 29 deletions
diff --git a/tests/block_test_util.go b/tests/block_test_util.go index 5fdc6402e..450ef86a1 100644 --- a/tests/block_test_util.go +++ b/tests/block_test_util.go @@ -245,7 +245,7 @@ func (t *BlockTest) TryBlocksInsert(chainManager *core.ChainManager) error { if b.BlockHeader == nil { continue // OK - block is supposed to be invalid, continue with next block } else { - return fmt.Errorf("Block RLP decoding failed when expected to succeed: ", err) + return fmt.Errorf("Block RLP decoding failed when expected to succeed: %v", err) } } // RLP decoding worked, try to insert into chain: @@ -254,7 +254,7 @@ func (t *BlockTest) TryBlocksInsert(chainManager *core.ChainManager) error { if b.BlockHeader == nil { continue // OK - block is supposed to be invalid, continue with next block } else { - return fmt.Errorf("Block insertion into chain failed: ", err) + return fmt.Errorf("Block insertion into chain failed: %v", err) } } if b.BlockHeader == nil { @@ -262,7 +262,7 @@ func (t *BlockTest) TryBlocksInsert(chainManager *core.ChainManager) error { } err = t.validateBlockHeader(b.BlockHeader, cb.Header()) if err != nil { - return fmt.Errorf("Block header validation failed: ", err) + return fmt.Errorf("Block header validation failed: %v", err) } } return nil @@ -286,7 +286,7 @@ func (s *BlockTest) validateBlockHeader(h *btHeader, h2 *types.Header) error { expectedNonce := mustConvertBytes(h.Nonce) if !bytes.Equal(expectedNonce, h2.Nonce[:]) { - return fmt.Errorf("Nonce: expected: %v, decoded: %v", expectedNonce, h2.Nonce[:]) + return fmt.Errorf("Nonce: expected: %v, decoded: %v", expectedNonce, h2.Nonce) } expectedNumber := mustConvertBigInt(h.Number, 16) @@ -423,9 +423,8 @@ func mustConvertHeader(in btHeader) *types.Header { GasLimit: mustConvertBigInt(in.GasLimit, 16), Difficulty: mustConvertBigInt(in.Difficulty, 16), Time: mustConvertUint(in.Timestamp, 16), + Nonce: types.EncodeNonce(mustConvertUint(in.Nonce, 16)), } - // XXX cheats? :-) - header.SetNonce(mustConvertUint(in.Nonce, 16)) return header } diff --git a/tests/transaction_test_util.go b/tests/transaction_test_util.go index 45caf26fd..1c92090db 100644 --- a/tests/transaction_test_util.go +++ b/tests/transaction_test_util.go @@ -152,54 +152,53 @@ func verifyTxFields(txTest TransactionTest, decodedTx *types.Transaction) (err e } expectedData := mustConvertBytes(txTest.Transaction.Data) - if !bytes.Equal(expectedData, decodedTx.Payload) { - return fmt.Errorf("Tx input data mismatch: %#v %#v", expectedData, decodedTx.Payload) + if !bytes.Equal(expectedData, decodedTx.Data()) { + return fmt.Errorf("Tx input data mismatch: %#v %#v", expectedData, decodedTx.Data()) } expectedGasLimit := mustConvertBigInt(txTest.Transaction.GasLimit, 16) - if expectedGasLimit.Cmp(decodedTx.GasLimit) != 0 { - return fmt.Errorf("GasLimit mismatch: %v %v", expectedGasLimit, decodedTx.GasLimit) + if expectedGasLimit.Cmp(decodedTx.Gas()) != 0 { + return fmt.Errorf("GasLimit mismatch: %v %v", expectedGasLimit, decodedTx.Gas()) } expectedGasPrice := mustConvertBigInt(txTest.Transaction.GasPrice, 16) - if expectedGasPrice.Cmp(decodedTx.Price) != 0 { - return fmt.Errorf("GasPrice mismatch: %v %v", expectedGasPrice, decodedTx.Price) + if expectedGasPrice.Cmp(decodedTx.GasPrice()) != 0 { + return fmt.Errorf("GasPrice mismatch: %v %v", expectedGasPrice, decodedTx.GasPrice()) } expectedNonce := mustConvertUint(txTest.Transaction.Nonce, 16) - if expectedNonce != decodedTx.AccountNonce { - return fmt.Errorf("Nonce mismatch: %v %v", expectedNonce, decodedTx.AccountNonce) + if expectedNonce != decodedTx.Nonce() { + return fmt.Errorf("Nonce mismatch: %v %v", expectedNonce, decodedTx.Nonce()) } - expectedR := common.Bytes2Big(mustConvertBytes(txTest.Transaction.R)) - if expectedR.Cmp(decodedTx.R) != 0 { - return fmt.Errorf("R mismatch: %v %v", expectedR, decodedTx.R) + v, r, s := decodedTx.SignatureValues() + expectedR := mustConvertBigInt(txTest.Transaction.R, 16) + if r.Cmp(expectedR) != 0 { + return fmt.Errorf("R mismatch: %v %v", expectedR, r) } - - expectedS := common.Bytes2Big(mustConvertBytes(txTest.Transaction.S)) - if expectedS.Cmp(decodedTx.S) != 0 { - return fmt.Errorf("S mismatch: %v %v", expectedS, decodedTx.S) + expectedS := mustConvertBigInt(txTest.Transaction.S, 16) + if s.Cmp(expectedS) != 0 { + return fmt.Errorf("S mismatch: %v %v", expectedS, s) } - expectedV := mustConvertUint(txTest.Transaction.V, 16) - if expectedV != uint64(decodedTx.V) { - return fmt.Errorf("V mismatch: %v %v", expectedV, uint64(decodedTx.V)) + if uint64(v) != expectedV { + return fmt.Errorf("V mismatch: %v %v", expectedV, v) } expectedTo := mustConvertAddress(txTest.Transaction.To) - if decodedTx.Recipient == nil { + if decodedTx.To() == nil { if expectedTo != common.BytesToAddress([]byte{}) { // "empty" or "zero" address return fmt.Errorf("To mismatch when recipient is nil (contract creation): %v", expectedTo) } } else { - if expectedTo != *decodedTx.Recipient { - return fmt.Errorf("To mismatch: %v %v", expectedTo, *decodedTx.Recipient) + if expectedTo != *decodedTx.To() { + return fmt.Errorf("To mismatch: %v %v", expectedTo, *decodedTx.To()) } } expectedValue := mustConvertBigInt(txTest.Transaction.Value, 16) - if expectedValue.Cmp(decodedTx.Amount) != 0 { - return fmt.Errorf("Value mismatch: %v %v", expectedValue, decodedTx.Amount) + if expectedValue.Cmp(decodedTx.Value()) != 0 { + return fmt.Errorf("Value mismatch: %v %v", expectedValue, decodedTx.Value()) } return nil |