-
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
c9db8a6
commit 56b9f42
Showing
5 changed files
with
37 additions
and
97 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
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
33 changes: 33 additions & 0 deletions
33
packages/eth-rpc-adapter/src/__tests__/endpoint-tests/eth_getStorageAt.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,33 @@ | ||
import { describe, expect, it } from 'vitest'; | ||
|
||
import { deployErc20, eth_getStorageAt, testSetup } from '../utils'; | ||
import { hexZeroPad, parseEther } from 'ethers/lib/utils'; | ||
|
||
const { wallet } = testSetup; | ||
|
||
describe('eth_getStorageAt', () => { | ||
it('get correct storage', async () => { | ||
const token = await deployErc20(wallet); | ||
|
||
const _getStorageAtForToken = async (slot: string) => { | ||
return (await eth_getStorageAt([token.address, slot, 'latest'])).data.result; | ||
}; | ||
|
||
const totalSupplyStorage = hexZeroPad(parseEther('1000000000').toHexString(), 32); | ||
|
||
expect((await _getStorageAtForToken('0x0000000000000000000000000000000000000000000000000000000000000000'))).to.equal(totalSupplyStorage); | ||
expect((await _getStorageAtForToken('0x0'))).to.equal(totalSupplyStorage); | ||
|
||
expect((await _getStorageAtForToken('0x1'))).to.equal( | ||
'0x0000000000000000000000000000000000000000000000000000000000000000' | ||
); | ||
|
||
expect((await _getStorageAtForToken('0x2'))).to.equal( | ||
'0x0000000000000000000000000000000000000000000000000000000000000000' | ||
); | ||
|
||
expect((await _getStorageAtForToken('0x3'))).to.equal( | ||
'0x54657374546f6b656e0000000000000000000000000000000000000000000012' | ||
); | ||
}); | ||
}); |
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