-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c2b1374
commit 4419adb
Showing
4 changed files
with
92 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
packages/eth-rpc-adapter/src/__tests__/endpoint-tests/blocktag.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { | ||
deployErc20, | ||
eth_getBalance, | ||
eth_getBlockByNumber, | ||
eth_getCode, | ||
eth_getTransactionCount, | ||
eth_isBlockFinalized, | ||
testSetup, | ||
} from '../utils'; | ||
|
||
const { wallet } = testSetup; | ||
|
||
describe('finalized/safe/pending blocktag', () => { | ||
/* ---------- | ||
latest block === finalized block in local setup | ||
---------- */ | ||
|
||
it('eth_getCode', async () => { | ||
const token = await deployErc20(wallet); | ||
|
||
const res = (await eth_getCode([token.address, 'latest'])).data.result; | ||
const resF = (await eth_getCode([token.address, 'finalized'])).data.result; | ||
const resS = (await eth_getCode([token.address, 'safe'])).data.result; | ||
const resP = (await eth_getCode([token.address, 'pending'])).data.result; | ||
|
||
expect(res).not.to.be.undefined; | ||
expect(res).to.equal(resF); | ||
expect(res).to.equal(resS); | ||
expect(res).to.equal(resP); | ||
}); | ||
|
||
it('eth_getTransactionCount', async () => { | ||
const res = (await eth_getTransactionCount([wallet.address, 'latest'])).data.result; | ||
const resF = (await eth_getTransactionCount([wallet.address, 'finalized'])).data.result; | ||
const resS = (await eth_getTransactionCount([wallet.address, 'safe'])).data.result; | ||
|
||
await deployErc20(wallet, false); | ||
const resP = (await eth_getTransactionCount([wallet.address, 'pending'])).data.result; | ||
|
||
expect(res).to.equal(resF); | ||
expect(res).to.equal(resS); | ||
expect(Number(res)).to.equal(Number(resP) - 1); // pending should have +1 nonce | ||
}); | ||
|
||
it('eth_getBalance', async () => { | ||
const res = (await eth_getBalance([wallet.address, 'latest'])).data.result; | ||
const resF = (await eth_getBalance([wallet.address, 'finalized'])).data.result; | ||
const resS = (await eth_getBalance([wallet.address, 'safe'])).data.result; | ||
const resP = (await eth_getBalance([wallet.address, 'pending'])).data.result; | ||
|
||
expect(parseInt(res)).to.greaterThan(0); | ||
expect(res).to.equal(resF); | ||
expect(res).to.equal(resS); | ||
expect(res).to.equal(resP); | ||
}); | ||
|
||
it('eth_getBlockByNumber', async () => { | ||
const res = (await eth_getBlockByNumber(['latest', false])).data.result; | ||
const resF = (await eth_getBlockByNumber(['finalized', false])).data.result; | ||
const resS = (await eth_getBlockByNumber(['safe', false])).data.result; | ||
const resP = (await eth_getBlockByNumber(['pending', false])).data.result; | ||
|
||
expect(res).not.to.be.undefined; | ||
expect(res).to.deep.equal(resF); | ||
expect(res).to.deep.equal(resS); | ||
expect(res).to.deep.equal(resP); | ||
}); | ||
|
||
it('eth_isBlockFinalized', async () => { | ||
const res = (await eth_isBlockFinalized(['latest'])).data.result; | ||
const resF = (await eth_isBlockFinalized(['finalized'])).data.result; | ||
const resS = (await eth_isBlockFinalized(['safe'])).data.result; | ||
|
||
expect(res).to.equal(true); | ||
expect(res).to.deep.equal(resF); | ||
expect(res).to.deep.equal(resS); | ||
}); | ||
|
||
// don't care about these | ||
it.skip('eth_getBlockTransactionCountByNumber', async () => { }); | ||
it.skip('eth_getTransactionByBlockNumberAndIndex', async () => { }); | ||
it.skip('eth_getUncleCountByBlockNumber', async () => { }); | ||
it.skip('eth_getUncleByBlockNumberAndIndex', async () => { }); | ||
|
||
// too lazy to test these | ||
it.skip('eth_call', async () => { }); | ||
it.skip('eth_getStorageAt', async () => { }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters