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

View File

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

View File

@ -34,7 +34,7 @@ var _ = Describe("Basic integration test", func() {
var contractErr error
var txErr error
Describe("get Block", func() {
Describe("Get Block", func() {
BeforeEach(func() {
contract, contractErr = integration.DeployContract()
Expect(contractErr).ToNot(HaveOccurred())
@ -43,7 +43,7 @@ var _ = Describe("Basic integration test", func() {
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)
gethBlock, err := gethClient.BlockByNumber(ctx, blockNum)
@ -55,7 +55,7 @@ var _ = Describe("Basic integration test", func() {
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)
Expect(err).To(MatchError(ethereum.NotFound))
Expect(gethBlock).To(BeZero())
@ -65,7 +65,7 @@ var _ = Describe("Basic integration test", func() {
Expect(ipldBlock).To(BeZero())
})
It("get block by number", func() {
It("gets block by number", func() {
blockNum := big.NewInt(contract.BlockNumber)
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))
})
It("get block by hash", func() {
It("gets block by hash", func() {
gethBlock, err := gethClient.BlockByHash(ctx, contract.BlockHash)
Expect(err).ToNot(HaveOccurred())

View File

@ -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,10 +131,18 @@ 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())
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()
@ -186,10 +195,10 @@ var (
"type": hexutil.Uint64(types.LegacyTxType),
}
)
var (
db *sqlx.DB
api *eth.PublicEthAPI
chainConfig = params.TestChainConfig
)
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 {

View File

@ -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),

View File

@ -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),

View File

@ -24,7 +24,7 @@ set -x
if [[ -z $SKIP_BUILD ]]; then
$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
$laconic_so build-containers \
--exclude cerc/ipld-eth-server

View File

@ -5,7 +5,7 @@ services:
restart: on-failure
depends_on:
- 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:
DATABASE_USER: "vdbm"
DATABASE_NAME: "cerc_testing"

View File

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