Changed R S to big int and fixed tests
This commit is contained in:
parent
eb8f0b85f7
commit
eb1c26746d
@ -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)
|
||||
}
|
||||
|
@ -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,
|
||||
},
|
||||
})
|
||||
|
@ -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 {
|
||||
|
@ -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"),
|
||||
}
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user