Commit 7cb05416 authored by Ubuntu's avatar Ubuntu

check sign tx error

parent 86fce5f4
......@@ -183,9 +183,9 @@ func TestGrpcServer(t *testing.T) {
}
}
func pricedTransaction(to common.Address, nonce uint64, gaslimit uint64, gasprice *big.Int, key *ecdsa.PrivateKey) *types.Transaction {
tx, _ := types.SignTx(types.NewTransaction(nonce, to, big.NewInt(100), gaslimit, gasprice, nil), types.HomesteadSigner{}, key)
return tx
func pricedTransaction(to common.Address, nonce uint64, gaslimit uint64, gasprice *big.Int, key *ecdsa.PrivateKey) (*types.Transaction, error) {
return types.SignTx(types.NewTransaction(nonce, to, big.NewInt(100), gaslimit, gasprice, nil), types.HomesteadSigner{}, key)
}
// go test -v -run EthTx -bench=. -benchtime=3s
......@@ -255,7 +255,12 @@ func int() {
fromAddr = crypto.PubkeyToAddress(*publicKeyECDSA)
remote, _ := crypto.GenerateKey()
tx = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
var err error
tx, err = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
if err != nil {
fmt.Println("pricedTransaction", err.Error())
}
}
......@@ -334,7 +339,13 @@ func BenchmarkEthTx(b *testing.B) {
fromAddr = crypto.PubkeyToAddress(*publicKeyECDSA)
remote, _ := crypto.GenerateKey()
tx = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
var err error
tx, err = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
if err != nil {
b.Fatal(err)
}
}
once.Do(onceFunc)
......@@ -405,7 +416,13 @@ func BenchmarkStdTx(b *testing.B) {
fromAddr = crypto.PubkeyToAddress(*publicKeyECDSA)
remote, _ := crypto.GenerateKey()
tx = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
var err error
tx, err = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
if err != nil {
b.Fatal(err)
}
}
once.Do(onceFunc)
......@@ -475,7 +492,13 @@ func BenchmarkAnyTxEth(b *testing.B) {
fromAddr = crypto.PubkeyToAddress(*publicKeyECDSA)
remote, _ := crypto.GenerateKey()
tx = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
var err error
tx, err = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
if err != nil {
b.Fatal(err)
}
}
once.Do(onceFunc)
......@@ -550,7 +573,13 @@ func BenchmarkAnyTxStd(b *testing.B) {
fromAddr = crypto.PubkeyToAddress(*publicKeyECDSA)
remote, _ := crypto.GenerateKey()
tx = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
var err error
tx, err = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
if err != nil {
b.Fatal(err)
}
}
once.Do(onceFunc)
......@@ -625,7 +654,13 @@ func BenchmarkBytesEth(b *testing.B) {
fromAddr = crypto.PubkeyToAddress(*publicKeyECDSA)
remote, _ := crypto.GenerateKey()
tx = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
var err error
tx, err = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
if err != nil {
b.Fatal(err)
}
}
once.Do(onceFunc)
......@@ -712,7 +747,14 @@ func TestAnyTx(t *testing.T) {
fromAddr = crypto.PubkeyToAddress(*publicKeyECDSA)
remote, _ := crypto.GenerateKey()
tx = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
var err error
tx, err = pricedTransaction(crypto.PubkeyToAddress(remote.PublicKey), 0, 100000, big.NewInt(1), local)
if err != nil {
t.Fatal(err)
}
}
once.Do(onceFunc)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment