test fixes

This commit is contained in:
Roy Crihfield 2024-04-18 21:54:42 +08:00
parent 5406c8b644
commit 319a331d03
9 changed files with 39 additions and 31 deletions

View File

@ -29,7 +29,7 @@ jobs:
- name: Build and run tests - name: Build and run tests
run: | run: |
go install github.com/onsi/ginkgo/v2/ginkgo go install github.com/onsi/ginkgo/v2/ginkgo
ginkgo -v -r --skipPackage=./integration ginkgo -v -r --skip-package=./integration
integration-test: integration-test:
name: Run integration tests name: Run integration tests
@ -52,7 +52,7 @@ jobs:
- name: Install Python - name: Install Python
uses: actions/setup-python@v4 uses: actions/setup-python@v4
with: with:
python-version: '3.11' python-version: 3.11
- name: Install stack-orchestrator - name: Install stack-orchestrator
uses: actions/checkout@v3 uses: actions/checkout@v3
with: with:

View File

@ -22,13 +22,13 @@ var _ = Describe("Direct proxy integration test", Label("proxy"), func() {
var contractErr error var contractErr error
var txErr error var txErr error
Describe("get Block", func() { Describe("Get Block", func() {
BeforeEach(func() { BeforeEach(func() {
contract, contractErr = integration.DeployContract() contract, contractErr = integration.DeployContract()
Expect(contractErr).ToNot(HaveOccurred()) Expect(contractErr).ToNot(HaveOccurred())
}) })
It("get not existing block by number", func() { It("gets not existing block by number", func() {
blockNum := contract.BlockNumber + 100 blockNum := contract.BlockNumber + 100
gethBlock, err := gethClient.BlockByNumber(ctx, big.NewInt(blockNum)) gethBlock, err := gethClient.BlockByNumber(ctx, big.NewInt(blockNum))
@ -40,7 +40,7 @@ var _ = Describe("Direct proxy integration test", Label("proxy"), func() {
Expect(ipldBlock).To(BeZero()) Expect(ipldBlock).To(BeZero())
}) })
It("get not existing block by hash", func() { It("gets not existing block by hash", func() {
gethBlock, err := gethClient.BlockByHash(ctx, nonExistingBlockHash) gethBlock, err := gethClient.BlockByHash(ctx, nonExistingBlockHash)
Expect(err).To(MatchError(ethereum.NotFound)) Expect(err).To(MatchError(ethereum.NotFound))
Expect(gethBlock).To(BeZero()) Expect(gethBlock).To(BeZero())
@ -50,7 +50,7 @@ var _ = Describe("Direct proxy integration test", Label("proxy"), func() {
Expect(ipldBlock).To(BeZero()) Expect(ipldBlock).To(BeZero())
}) })
It("get block by number", func() { It("gets block by number", func() {
blockNum := contract.BlockNumber blockNum := contract.BlockNumber
_, err := gethClient.BlockByNumber(ctx, big.NewInt(blockNum)) _, err := gethClient.BlockByNumber(ctx, big.NewInt(blockNum))
@ -60,7 +60,7 @@ var _ = Describe("Direct proxy integration test", Label("proxy"), func() {
Expect(err).To(HaveOccurred()) Expect(err).To(HaveOccurred())
}) })
It("get block by hash", func() { It("gets block by hash", func() {
_, err := gethClient.BlockByHash(ctx, contract.BlockHash) _, err := gethClient.BlockByHash(ctx, contract.BlockHash)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())

View File

@ -34,7 +34,7 @@ var _ = Describe("Basic integration test", func() {
var contractErr error var contractErr error
var txErr error var txErr error
Describe("get Block", func() { Describe("Get Block", func() {
BeforeEach(func() { BeforeEach(func() {
contract, contractErr = integration.DeployContract() contract, contractErr = integration.DeployContract()
Expect(contractErr).ToNot(HaveOccurred()) Expect(contractErr).ToNot(HaveOccurred())
@ -43,7 +43,7 @@ var _ = Describe("Basic integration test", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
}) })
It("get not existing block by number", func() { It("gets not existing block by number", func() {
blockNum := big.NewInt(contract.BlockNumber + 100) blockNum := big.NewInt(contract.BlockNumber + 100)
gethBlock, err := gethClient.BlockByNumber(ctx, blockNum) gethBlock, err := gethClient.BlockByNumber(ctx, blockNum)
@ -55,7 +55,7 @@ var _ = Describe("Basic integration test", func() {
Expect(ipldBlock).To(BeZero()) Expect(ipldBlock).To(BeZero())
}) })
It("get not existing block by hash", func() { It("gets not existing block by hash", func() {
gethBlock, err := gethClient.BlockByHash(ctx, nonExistingBlockHash) gethBlock, err := gethClient.BlockByHash(ctx, nonExistingBlockHash)
Expect(err).To(MatchError(ethereum.NotFound)) Expect(err).To(MatchError(ethereum.NotFound))
Expect(gethBlock).To(BeZero()) Expect(gethBlock).To(BeZero())
@ -65,7 +65,7 @@ var _ = Describe("Basic integration test", func() {
Expect(ipldBlock).To(BeZero()) Expect(ipldBlock).To(BeZero())
}) })
It("get block by number", func() { It("gets block by number", func() {
blockNum := big.NewInt(contract.BlockNumber) blockNum := big.NewInt(contract.BlockNumber)
gethBlock, err := gethClient.BlockByNumber(ctx, blockNum) gethBlock, err := gethClient.BlockByNumber(ctx, blockNum)
@ -84,7 +84,7 @@ var _ = Describe("Basic integration test", func() {
Expect(types.TxDifference(gethTxs, ipldTxs).Len()).To(Equal(0)) Expect(types.TxDifference(gethTxs, ipldTxs).Len()).To(Equal(0))
}) })
It("get block by hash", func() { It("gets block by hash", func() {
gethBlock, err := gethClient.BlockByHash(ctx, contract.BlockHash) gethBlock, err := gethClient.BlockByHash(ctx, contract.BlockHash)
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())

View File

@ -44,11 +44,13 @@ var (
randomAddr = common.HexToAddress("0x1C3ab14BBaD3D99F4203bd7a11aCB94882050E6f") randomAddr = common.HexToAddress("0x1C3ab14BBaD3D99F4203bd7a11aCB94882050E6f")
randomHash = crypto.Keccak256Hash(randomAddr.Bytes()) randomHash = crypto.Keccak256Hash(randomAddr.Bytes())
number = rpc.BlockNumber(test_helpers.BlockNumber1) number = rpc.BlockNumber(test_helpers.BlockNumber1)
blockTime = test_helpers.BlockTime1
londonBlockNum = rpc.BlockNumber(test_helpers.LondonBlockNum) londonBlockNum = rpc.BlockNumber(test_helpers.LondonBlockNum)
wrongNumber = number + 1 wrongNumber = number + 1
blockHash = test_helpers.MockBlock.Header().Hash() blockHash = test_helpers.MockBlock.Header().Hash()
baseFee = test_helpers.MockLondonBlock.BaseFee() baseFee = test_helpers.MockLondonBlock.BaseFee()
ctx = context.Background() ctx = context.Background()
chainConfig = &*params.TestChainConfig
expectedBlock = map[string]interface{}{ expectedBlock = map[string]interface{}{
"number": (*hexutil.Big)(test_helpers.MockBlock.Number()), "number": (*hexutil.Big)(test_helpers.MockBlock.Number()),
@ -82,7 +84,6 @@ var (
"miner": test_helpers.MockBlock.Header().Coinbase, "miner": test_helpers.MockBlock.Header().Coinbase,
"difficulty": (*hexutil.Big)(test_helpers.MockBlock.Header().Difficulty), "difficulty": (*hexutil.Big)(test_helpers.MockBlock.Header().Difficulty),
"extraData": hexutil.Bytes(test_helpers.MockBlock.Header().Extra), "extraData": hexutil.Bytes(test_helpers.MockBlock.Header().Extra),
"size": hexutil.Uint64(test_helpers.MockBlock.Header().Size()),
"gasLimit": hexutil.Uint64(test_helpers.MockBlock.Header().GasLimit), "gasLimit": hexutil.Uint64(test_helpers.MockBlock.Header().GasLimit),
"gasUsed": hexutil.Uint64(test_helpers.MockBlock.Header().GasUsed), "gasUsed": hexutil.Uint64(test_helpers.MockBlock.Header().GasUsed),
"timestamp": hexutil.Uint64(test_helpers.MockBlock.Header().Time), "timestamp": hexutil.Uint64(test_helpers.MockBlock.Header().Time),
@ -130,14 +131,22 @@ var (
"receiptsRoot": test_helpers.MockUncles[1].ReceiptHash, "receiptsRoot": test_helpers.MockUncles[1].ReceiptHash,
"uncles": []common.Hash{}, "uncles": []common.Hash{},
} }
expectedTransaction = eth.NewRPCTransaction(test_helpers.MockTransactions[0], test_helpers.MockBlock.Hash(), test_helpers.MockBlock.NumberU64(), 0, test_helpers.MockBlock.BaseFee()) 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(), 1, test_helpers.MockBlock.BaseFee()) 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(), 2, test_helpers.MockBlock.BaseFee()) 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(), 0, test_helpers.MockLondonBlock.BaseFee()) expectedLondonTransaction = eth.NewRPCTransaction(
expectRawTx, _ = test_helpers.MockTransactions[0].MarshalBinary() test_helpers.MockLondonTransactions[0],
expectRawTx2, _ = test_helpers.MockTransactions[1].MarshalBinary() test_helpers.MockLondonBlock.Hash(),
expectRawTx3, _ = test_helpers.MockTransactions[2].MarshalBinary() test_helpers.MockLondonBlock.NumberU64(),
expectedReceipt = map[string]interface{}{ 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, "blockHash": blockHash,
"blockNumber": hexutil.Uint64(uint64(number.Int64())), "blockNumber": hexutil.Uint64(uint64(number.Int64())),
"transactionHash": expectedTransaction.Hash, "transactionHash": expectedTransaction.Hash,
@ -186,10 +195,10 @@ var (
"type": hexutil.Uint64(types.LegacyTxType), "type": hexutil.Uint64(types.LegacyTxType),
} }
) )
var ( var (
db *sqlx.DB db *sqlx.DB
api *eth.PublicEthAPI api *eth.PublicEthAPI
chainConfig = params.TestChainConfig
) )
var _ = BeforeSuite(func() { var _ = BeforeSuite(func() {
@ -314,7 +323,7 @@ var _ = Describe("API", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
transactions := make([]interface{}, len(test_helpers.MockBlock.Transactions())) transactions := make([]interface{}, len(test_helpers.MockBlock.Transactions()))
for i, trx := range 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 expectedBlock["transactions"] = transactions
for key, val := range expectedBlock { for key, val := range expectedBlock {
@ -368,7 +377,7 @@ var _ = Describe("API", func() {
Expect(err).ToNot(HaveOccurred()) Expect(err).ToNot(HaveOccurred())
transactions := make([]interface{}, len(test_helpers.MockBlock.Transactions())) transactions := make([]interface{}, len(test_helpers.MockBlock.Transactions()))
for i, trx := range 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 expectedBlock["transactions"] = transactions
for key, val := range expectedBlock { for key, val := range expectedBlock {

View File

@ -152,7 +152,6 @@ var _ = BeforeSuite(func() {
"miner": canonicalHeader.Coinbase, "miner": canonicalHeader.Coinbase,
"difficulty": (*hexutil.Big)(canonicalHeader.Difficulty), "difficulty": (*hexutil.Big)(canonicalHeader.Difficulty),
"extraData": hexutil.Bytes([]byte{}), "extraData": hexutil.Bytes([]byte{}),
"size": hexutil.Uint64(canonicalHeader.Size()),
"gasLimit": hexutil.Uint64(canonicalHeader.GasLimit), "gasLimit": hexutil.Uint64(canonicalHeader.GasLimit),
"gasUsed": hexutil.Uint64(canonicalHeader.GasUsed), "gasUsed": hexutil.Uint64(canonicalHeader.GasUsed),
"timestamp": hexutil.Uint64(canonicalHeader.Time), "timestamp": hexutil.Uint64(canonicalHeader.Time),

View File

@ -295,7 +295,7 @@ var (
LondonBlockNum = (BlockNumber1 + 2) LondonBlockNum = (BlockNumber1 + 2)
LondonBlockTime = BlockTime1 + 1 LondonBlockTime = BlockTime1 + 1
MockLondonHeader = types.Header{ MockLondonHeader = types.Header{
Time: 0, Time: LondonBlockTime,
Number: big.NewInt(LondonBlockNum), Number: big.NewInt(LondonBlockNum),
Root: common.HexToHash("0x00"), Root: common.HexToHash("0x00"),
Difficulty: big.NewInt(5000000), Difficulty: big.NewInt(5000000),

View File

@ -24,7 +24,7 @@ set -x
if [[ -z $SKIP_BUILD ]]; then if [[ -z $SKIP_BUILD ]]; then
$laconic_so setup-repositories \ $laconic_so setup-repositories \
--exclude github.com/cerc-io/ipld-eth-server --exclude git.vdb.to/cerc-io/ipld-eth-server
# Assume the tested image has been built separately # Assume the tested image has been built separately
$laconic_so build-containers \ $laconic_so build-containers \
--exclude cerc/ipld-eth-server --exclude cerc/ipld-eth-server

View File

@ -5,7 +5,7 @@ services:
restart: on-failure restart: on-failure
depends_on: depends_on:
- ipld-eth-db - ipld-eth-db
image: git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:v5.0.5-alpha image: git.vdb.to/cerc-io/ipld-eth-db/ipld-eth-db:v5.2.1-alpha
environment: environment:
DATABASE_USER: "vdbm" DATABASE_USER: "vdbm"
DATABASE_NAME: "cerc_testing" DATABASE_NAME: "cerc_testing"

View File

@ -28,7 +28,7 @@ services:
contract-deployer: contract-deployer:
restart: on-failure restart: on-failure
image: cerc/ipld-eth-server/contract-deployer:local image: cerc/ipld-eth-server/test-contract-deployer:local
build: ./contract build: ./contract
networks: networks:
- test_default - test_default