fix unit tests
This commit is contained in:
parent
3ccf74c122
commit
3019384c0d
@ -44,11 +44,13 @@ var (
|
||||
randomAddr = common.HexToAddress("0x1C3ab14BBaD3D99F4203bd7a11aCB94882050E6f")
|
||||
randomHash = crypto.Keccak256Hash(randomAddr.Bytes())
|
||||
number = rpc.BlockNumber(test_helpers.BlockNumber1)
|
||||
blockTime = test_helpers.BlockTime1
|
||||
londonBlockNum = rpc.BlockNumber(test_helpers.LondonBlockNum)
|
||||
wrongNumber = number + 1
|
||||
blockHash = test_helpers.MockBlock.Header().Hash()
|
||||
baseFee = test_helpers.MockLondonBlock.BaseFee()
|
||||
ctx = context.Background()
|
||||
chainConfig = &*params.TestChainConfig
|
||||
|
||||
expectedBlock = map[string]interface{}{
|
||||
"number": (*hexutil.Big)(test_helpers.MockBlock.Number()),
|
||||
@ -82,7 +84,6 @@ var (
|
||||
"miner": test_helpers.MockBlock.Header().Coinbase,
|
||||
"difficulty": (*hexutil.Big)(test_helpers.MockBlock.Header().Difficulty),
|
||||
"extraData": hexutil.Bytes(test_helpers.MockBlock.Header().Extra),
|
||||
"size": hexutil.Uint64(test_helpers.MockBlock.Header().Size()),
|
||||
"gasLimit": hexutil.Uint64(test_helpers.MockBlock.Header().GasLimit),
|
||||
"gasUsed": hexutil.Uint64(test_helpers.MockBlock.Header().GasUsed),
|
||||
"timestamp": hexutil.Uint64(test_helpers.MockBlock.Header().Time),
|
||||
@ -130,14 +131,22 @@ var (
|
||||
"receiptsRoot": test_helpers.MockUncles[1].ReceiptHash,
|
||||
"uncles": []common.Hash{},
|
||||
}
|
||||
expectedTransaction = eth.NewRPCTransaction(test_helpers.MockTransactions[0], test_helpers.MockBlock.Hash(), test_helpers.MockBlock.NumberU64(), 0, test_helpers.MockBlock.BaseFee())
|
||||
expectedTransaction2 = eth.NewRPCTransaction(test_helpers.MockTransactions[1], test_helpers.MockBlock.Hash(), test_helpers.MockBlock.NumberU64(), 1, test_helpers.MockBlock.BaseFee())
|
||||
expectedTransaction3 = eth.NewRPCTransaction(test_helpers.MockTransactions[2], test_helpers.MockBlock.Hash(), test_helpers.MockBlock.NumberU64(), 2, test_helpers.MockBlock.BaseFee())
|
||||
expectedLondonTransaction = eth.NewRPCTransaction(test_helpers.MockLondonTransactions[0], test_helpers.MockLondonBlock.Hash(), test_helpers.MockLondonBlock.NumberU64(), 0, test_helpers.MockLondonBlock.BaseFee())
|
||||
expectRawTx, _ = test_helpers.MockTransactions[0].MarshalBinary()
|
||||
expectRawTx2, _ = test_helpers.MockTransactions[1].MarshalBinary()
|
||||
expectRawTx3, _ = test_helpers.MockTransactions[2].MarshalBinary()
|
||||
expectedReceipt = map[string]interface{}{
|
||||
expectedTransaction = eth.NewRPCTransaction(test_helpers.MockTransactions[0], test_helpers.MockBlock.Hash(), test_helpers.MockBlock.NumberU64(), blockTime, 0, test_helpers.MockBlock.BaseFee(), chainConfig)
|
||||
expectedTransaction2 = eth.NewRPCTransaction(test_helpers.MockTransactions[1], test_helpers.MockBlock.Hash(), test_helpers.MockBlock.NumberU64(), blockTime, 1, test_helpers.MockBlock.BaseFee(), chainConfig)
|
||||
expectedTransaction3 = eth.NewRPCTransaction(test_helpers.MockTransactions[2], test_helpers.MockBlock.Hash(), test_helpers.MockBlock.NumberU64(), blockTime, 2, test_helpers.MockBlock.BaseFee(), chainConfig)
|
||||
expectedLondonTransaction = eth.NewRPCTransaction(
|
||||
test_helpers.MockLondonTransactions[0],
|
||||
test_helpers.MockLondonBlock.Hash(),
|
||||
test_helpers.MockLondonBlock.NumberU64(),
|
||||
test_helpers.MockLondonBlock.Time(),
|
||||
0,
|
||||
test_helpers.MockLondonBlock.BaseFee(),
|
||||
chainConfig,
|
||||
)
|
||||
expectRawTx, _ = test_helpers.MockTransactions[0].MarshalBinary()
|
||||
expectRawTx2, _ = test_helpers.MockTransactions[1].MarshalBinary()
|
||||
expectRawTx3, _ = test_helpers.MockTransactions[2].MarshalBinary()
|
||||
expectedReceipt = map[string]interface{}{
|
||||
"blockHash": blockHash,
|
||||
"blockNumber": hexutil.Uint64(uint64(number.Int64())),
|
||||
"transactionHash": expectedTransaction.Hash,
|
||||
@ -186,10 +195,10 @@ var (
|
||||
"type": hexutil.Uint64(types.LegacyTxType),
|
||||
}
|
||||
)
|
||||
|
||||
var (
|
||||
db *sqlx.DB
|
||||
api *eth.PublicEthAPI
|
||||
chainConfig = params.TestChainConfig
|
||||
db *sqlx.DB
|
||||
api *eth.PublicEthAPI
|
||||
)
|
||||
|
||||
var _ = BeforeSuite(func() {
|
||||
@ -314,7 +323,7 @@ var _ = Describe("API", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
transactions := make([]interface{}, len(test_helpers.MockBlock.Transactions()))
|
||||
for i, trx := range test_helpers.MockBlock.Transactions() {
|
||||
transactions[i] = eth.NewRPCTransactionFromBlockHash(test_helpers.MockBlock, trx.Hash())
|
||||
transactions[i] = eth.NewRPCTransactionFromBlockHash(test_helpers.MockBlock, trx.Hash(), chainConfig)
|
||||
}
|
||||
expectedBlock["transactions"] = transactions
|
||||
for key, val := range expectedBlock {
|
||||
@ -368,7 +377,7 @@ var _ = Describe("API", func() {
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
transactions := make([]interface{}, len(test_helpers.MockBlock.Transactions()))
|
||||
for i, trx := range test_helpers.MockBlock.Transactions() {
|
||||
transactions[i] = eth.NewRPCTransactionFromBlockHash(test_helpers.MockBlock, trx.Hash())
|
||||
transactions[i] = eth.NewRPCTransactionFromBlockHash(test_helpers.MockBlock, trx.Hash(), chainConfig)
|
||||
}
|
||||
expectedBlock["transactions"] = transactions
|
||||
for key, val := range expectedBlock {
|
||||
|
||||
@ -152,7 +152,6 @@ var _ = BeforeSuite(func() {
|
||||
"miner": canonicalHeader.Coinbase,
|
||||
"difficulty": (*hexutil.Big)(canonicalHeader.Difficulty),
|
||||
"extraData": hexutil.Bytes([]byte{}),
|
||||
"size": hexutil.Uint64(canonicalHeader.Size()),
|
||||
"gasLimit": hexutil.Uint64(canonicalHeader.GasLimit),
|
||||
"gasUsed": hexutil.Uint64(canonicalHeader.GasUsed),
|
||||
"timestamp": hexutil.Uint64(canonicalHeader.Time),
|
||||
|
||||
@ -295,7 +295,7 @@ var (
|
||||
LondonBlockNum = (BlockNumber1 + 2)
|
||||
LondonBlockTime = BlockTime1 + 1
|
||||
MockLondonHeader = types.Header{
|
||||
Time: 0,
|
||||
Time: LondonBlockTime,
|
||||
Number: big.NewInt(LondonBlockNum),
|
||||
Root: common.HexToHash("0x00"),
|
||||
Difficulty: big.NewInt(5000000),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user