diff options
author | obscuren <geffobscura@gmail.com> | 2015-04-05 03:41:24 +0800 |
---|---|---|
committer | obscuren <geffobscura@gmail.com> | 2015-04-05 03:41:24 +0800 |
commit | eb1c26746d08e6a725fbd64b10f28105684e54db (patch) | |
tree | 1ba3f0f70d06f9cf585e1de052a0731bac57a9ef /core | |
parent | eb8f0b85f750b7843bb3909116ea71f85a1988a6 (diff) | |
download | go-tangerine-eb1c26746d08e6a725fbd64b10f28105684e54db.tar go-tangerine-eb1c26746d08e6a725fbd64b10f28105684e54db.tar.gz go-tangerine-eb1c26746d08e6a725fbd64b10f28105684e54db.tar.bz2 go-tangerine-eb1c26746d08e6a725fbd64b10f28105684e54db.tar.lz go-tangerine-eb1c26746d08e6a725fbd64b10f28105684e54db.tar.xz go-tangerine-eb1c26746d08e6a725fbd64b10f28105684e54db.tar.zst go-tangerine-eb1c26746d08e6a725fbd64b10f28105684e54db.zip |
Changed R S to big int and fixed tests
Diffstat (limited to 'core')
-rw-r--r-- | core/transaction_pool_test.go | 8 | ||||
-rw-r--r-- | core/types/block_test.go | 4 | ||||
-rw-r--r-- | core/types/transaction.go | 20 | ||||
-rw-r--r-- | core/types/transaction_test.go | 4 |
4 files changed, 28 insertions, 8 deletions
diff --git a/core/transaction_pool_test.go b/core/transaction_pool_test.go index a009a4c9d..abdc2709f 100644 --- a/core/transaction_pool_test.go +++ b/core/transaction_pool_test.go @@ -2,14 +2,15 @@ package core import ( "crypto/ecdsa" + "math/big" "testing" "github.com/ethereum/go-ethereum/common" + "github.com/ethereum/go-ethereum/core/state" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/ethdb" "github.com/ethereum/go-ethereum/event" - "github.com/ethereum/go-ethereum/core/state" ) // State query interface @@ -88,7 +89,10 @@ func TestRemoveInvalid(t *testing.T) { func TestInvalidSender(t *testing.T) { pool, _ := setup() - err := pool.ValidateTransaction(new(types.Transaction)) + tx := new(types.Transaction) + tx.R = new(big.Int) + tx.S = new(big.Int) + err := pool.ValidateTransaction(tx) if err != ErrInvalidSender { t.Errorf("expected %v, got %v", ErrInvalidSender, err) } diff --git a/core/types/block_test.go b/core/types/block_test.go index e4f6c38a5..b52ddffdc 100644 --- a/core/types/block_test.go +++ b/core/types/block_test.go @@ -44,8 +44,8 @@ func TestBlockEncoding(t *testing.T) { GasLimit: big.NewInt(50000), AccountNonce: 0, V: 27, - R: common.FromHex("9bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094f"), - S: common.FromHex("8a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1"), + R: common.String2Big("0x9bea4c4daac7c7c52e093e6a4c35dbbcf8856f1af7b059ba20253e70848d094f"), + S: common.String2Big("0x8a8fae537ce25ed8cb5af9adac3f141af69bd515bd2ba031522df09b97dd72b1"), Recipient: &to, }, }) diff --git a/core/types/transaction.go b/core/types/transaction.go index f5aa89a15..6f438ad9d 100644 --- a/core/types/transaction.go +++ b/core/types/transaction.go @@ -28,11 +28,27 @@ type Transaction struct { } func NewContractCreationTx(amount, gasLimit, gasPrice *big.Int, data []byte) *Transaction { - return &Transaction{Recipient: nil, Amount: amount, GasLimit: gasLimit, Price: gasPrice, Payload: data} + return &Transaction{ + Recipient: nil, + Amount: amount, + GasLimit: gasLimit, + Price: gasPrice, + Payload: data, + R: new(big.Int), + S: new(big.Int), + } } func NewTransactionMessage(to common.Address, amount, gasAmount, gasPrice *big.Int, data []byte) *Transaction { - return &Transaction{Recipient: &to, Amount: amount, GasLimit: gasAmount, Price: gasPrice, Payload: data} + return &Transaction{ + Recipient: &to, + Amount: amount, + GasLimit: gasAmount, + Price: gasPrice, + Payload: data, + R: new(big.Int), + S: new(big.Int), + } } func NewTransactionFromBytes(data []byte) *Transaction { diff --git a/core/types/transaction_test.go b/core/types/transaction_test.go index 6a015cb9a..dada424e9 100644 --- a/core/types/transaction_test.go +++ b/core/types/transaction_test.go @@ -30,8 +30,8 @@ var ( Amount: big.NewInt(10), Payload: common.FromHex("5544"), V: 28, - R: common.FromHex("98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a"), - S: common.FromHex("8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"), + R: common.String2Big("0x98ff921201554726367d2be8c804a7ff89ccf285ebc57dff8ae4c44b9c19ac4a"), + S: common.String2Big("0x8887321be575c8095f789dd4c743dfe42c1820f9231f98a962b210e3ac2452a3"), } ) |