use SignNewTx

Signed-off-by: Guillaume Ballet <3272758+gballet@users.noreply.github.com>
This commit is contained in:
Guillaume Ballet 2024-11-04 09:15:10 +01:00
parent 0f0bf1749a
commit 782b8a45ea

View file

@ -163,20 +163,20 @@ func TestProcessVerkle(t *testing.T) {
// Add two contract creations in block #2 // Add two contract creations in block #2
if i == 1 { if i == 1 {
tx, _ = types.SignTx(types.NewTx(&types.LegacyTx{Nonce: 6, tx, _ = types.SignNewTx(testKey, signer, &types.LegacyTx{Nonce: 6,
Value: big.NewInt(16), Value: big.NewInt(16),
Gas: 3000000, Gas: 3000000,
GasPrice: big.NewInt(875000000), GasPrice: big.NewInt(875000000),
Data: code, Data: code,
}), signer, testKey) })
gen.AddTx(tx) gen.AddTx(tx)
tx, _ = types.SignTx(types.NewTx(&types.LegacyTx{Nonce: 7, tx, _ = types.SignNewTx(testKey, signer, &types.LegacyTx{Nonce: 7,
Value: big.NewInt(0), Value: big.NewInt(0),
Gas: 3000000, Gas: 3000000,
GasPrice: big.NewInt(875000000), GasPrice: big.NewInt(875000000),
Data: codeWithExtCodeCopy, Data: codeWithExtCodeCopy,
}), signer, testKey) })
gen.AddTx(tx) gen.AddTx(tx)
} }
}) })
@ -535,20 +535,20 @@ func TestProcessVerkleExtCodeHashOpcode(t *testing.T) {
if i == 0 { if i == 0 {
// Create dummy contract. // Create dummy contract.
tx, _ := types.SignTx(types.NewTx(&types.LegacyTx{Nonce: 0, tx, _ := types.SignNewTx(testKey, signer, &types.LegacyTx{Nonce: 0,
Value: big.NewInt(0), Value: big.NewInt(0),
Gas: 100_000, Gas: 100_000,
GasPrice: big.NewInt(875000000), GasPrice: big.NewInt(875000000),
Data: dummyContract, Data: dummyContract,
}), signer, testKey) })
gen.AddTx(tx) gen.AddTx(tx)
// Create contract with EXTCODEHASH opcode. // Create contract with EXTCODEHASH opcode.
tx, _ = types.SignTx(types.NewTx(&types.LegacyTx{Nonce: 1, tx, _ = types.SignNewTx(testKey, signer, &types.LegacyTx{Nonce: 1,
Value: big.NewInt(0), Value: big.NewInt(0),
Gas: 100_000, Gas: 100_000,
GasPrice: big.NewInt(875000000), GasPrice: big.NewInt(875000000),
Data: extCodeHashContract}), signer, testKey) Data: extCodeHashContract})
gen.AddTx(tx) gen.AddTx(tx)
} else { } else {
tx, _ := types.SignTx(types.NewTransaction(2, extCodeHashContractAddr, big.NewInt(0), 100_000, big.NewInt(875000000), nil), signer, testKey) tx, _ := types.SignTx(types.NewTransaction(2, extCodeHashContractAddr, big.NewInt(0), 100_000, big.NewInt(875000000), nil), signer, testKey)
@ -610,11 +610,11 @@ func TestProcessVerkleBalanceOpcode(t *testing.T) {
common.HexToAddress("0x6177843db3138ae69679A54b95cf345ED759450d").Bytes(), common.HexToAddress("0x6177843db3138ae69679A54b95cf345ED759450d").Bytes(),
[]byte{byte(vm.BALANCE)}) []byte{byte(vm.BALANCE)})
tx, _ := types.SignTx(types.NewTx(&types.LegacyTx{Nonce: 0, tx, _ := types.SignNewTx(testKey, signer, &types.LegacyTx{Nonce: 0,
Value: big.NewInt(0), Value: big.NewInt(0),
Gas: 100_000, Gas: 100_000,
GasPrice: big.NewInt(875000000), GasPrice: big.NewInt(875000000),
Data: txData}), signer, testKey) Data: txData})
gen.AddTx(tx) gen.AddTx(tx)
}) })
@ -689,12 +689,12 @@ func TestProcessVerkleSelfDestructInSeparateTx(t *testing.T) {
if i == 0 { if i == 0 {
// Create selfdestruct contract, sending 42 wei. // Create selfdestruct contract, sending 42 wei.
tx, _ := types.SignTx(types.NewTx(&types.LegacyTx{Nonce: 0, tx, _ := types.SignNewTx(testKey, signer, &types.LegacyTx{Nonce: 0,
Value: big.NewInt(42), Value: big.NewInt(42),
Gas: 100_000, Gas: 100_000,
GasPrice: big.NewInt(875000000), GasPrice: big.NewInt(875000000),
Data: selfDestructContract, Data: selfDestructContract,
}), signer, testKey) })
gen.AddTx(tx) gen.AddTx(tx)
} else { } else {
// Call it. // Call it.
@ -794,12 +794,12 @@ func TestProcessVerkleSelfDestructInSameTx(t *testing.T) {
_, _, _, _, statediffs := GenerateVerkleChainWithGenesis(gspec, beacon.New(ethash.NewFaker()), 1, func(i int, gen *BlockGen) { _, _, _, _, statediffs := GenerateVerkleChainWithGenesis(gspec, beacon.New(ethash.NewFaker()), 1, func(i int, gen *BlockGen) {
gen.SetPoS() gen.SetPoS()
tx, _ := types.SignTx(types.NewTx(&types.LegacyTx{Nonce: 0, tx, _ := types.SignNewTx(testKey, signer, &types.LegacyTx{Nonce: 0,
Value: big.NewInt(42), Value: big.NewInt(42),
Gas: 100_000, Gas: 100_000,
GasPrice: big.NewInt(875000000), GasPrice: big.NewInt(875000000),
Data: selfDestructContract, Data: selfDestructContract,
}), signer, testKey) })
gen.AddTx(tx) gen.AddTx(tx)
}) })
@ -899,12 +899,12 @@ func TestProcessVerkleSelfDestructInSeparateTxWithSelfBeneficiary(t *testing.T)
gen.SetPoS() gen.SetPoS()
if i == 0 { if i == 0 {
// Create self-destruct contract, sending 42 wei. // Create self-destruct contract, sending 42 wei.
tx, _ := types.SignTx(types.NewTx(&types.LegacyTx{Nonce: 0, tx, _ := types.SignNewTx(testKey, signer, &types.LegacyTx{Nonce: 0,
Value: big.NewInt(42), Value: big.NewInt(42),
Gas: 100_000, Gas: 100_000,
GasPrice: big.NewInt(875000000), GasPrice: big.NewInt(875000000),
Data: selfDestructContract, Data: selfDestructContract,
}), signer, testKey) })
gen.AddTx(tx) gen.AddTx(tx)
} else { } else {
// Call it. // Call it.
@ -977,12 +977,12 @@ func TestProcessVerkleSelfDestructInSameTxWithSelfBeneficiary(t *testing.T) {
_, _, _, _, stateDiffs := GenerateVerkleChainWithGenesis(gspec, beacon.New(ethash.NewFaker()), 1, func(i int, gen *BlockGen) { _, _, _, _, stateDiffs := GenerateVerkleChainWithGenesis(gspec, beacon.New(ethash.NewFaker()), 1, func(i int, gen *BlockGen) {
gen.SetPoS() gen.SetPoS()
tx, _ := types.SignTx(types.NewTx(&types.LegacyTx{Nonce: 0, tx, _ := types.SignNewTx(testKey, signer, &types.LegacyTx{Nonce: 0,
Value: big.NewInt(42), Value: big.NewInt(42),
Gas: 100_000, Gas: 100_000,
GasPrice: big.NewInt(875000000), GasPrice: big.NewInt(875000000),
Data: selfDestructContract, Data: selfDestructContract,
}), signer, testKey) })
gen.AddTx(tx) gen.AddTx(tx)
}) })
stateDiff := stateDiffs[0] // state difference of block 1 stateDiff := stateDiffs[0] // state difference of block 1
@ -1043,12 +1043,12 @@ func TestProcessVerkleSelfDestructInSameTxWithSelfBeneficiaryAndPrefundedAccount
_, _, _, _, stateDiffs := GenerateVerkleChainWithGenesis(gspec, beacon.New(ethash.NewFaker()), 1, func(i int, gen *BlockGen) { _, _, _, _, stateDiffs := GenerateVerkleChainWithGenesis(gspec, beacon.New(ethash.NewFaker()), 1, func(i int, gen *BlockGen) {
gen.SetPoS() gen.SetPoS()
tx, _ := types.SignTx(types.NewTx(&types.LegacyTx{Nonce: 0, tx, _ := types.SignNewTx(testKey, signer, &types.LegacyTx{Nonce: 0,
Value: big.NewInt(42), Value: big.NewInt(42),
Gas: 100_000, Gas: 100_000,
GasPrice: big.NewInt(875000000), GasPrice: big.NewInt(875000000),
Data: selfDestructContract, Data: selfDestructContract,
}), signer, testKey) })
gen.AddTx(tx) gen.AddTx(tx)
}) })
stateDiff := stateDiffs[0] // state difference of block 1 stateDiff := stateDiffs[0] // state difference of block 1