From 8ac6d48772d037c22793535e9ff5db0b1e5435e9 Mon Sep 17 00:00:00 2001 From: ramil Date: Wed, 21 Apr 2021 16:38:02 +0300 Subject: [PATCH] integration tests: get storage --- test/integration_test.go | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/integration_test.go b/test/integration_test.go index 3e695b6b..aa3d0286 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -265,6 +265,45 @@ var _ = Describe("Integration test", func() { }) }) + Describe("Get Storage", func() { + contract, contractErr = integration.DeployContract() + erc20TotalSupply, err := new(big.Int).SetString("1000000000000000000000", 10) + + It("gets ERC20 total supply (without block number)", func() { + Expect(contractErr).ToNot(HaveOccurred()) + Expect(err).ToNot(Equal(false)) + + totalSupplyIndex := "0x2" + + gethStorage, err := gethClient.StorageAt(ctx, common.HexToAddress(contract.Address), common.HexToHash(totalSupplyIndex), nil) + Expect(err).ToNot(HaveOccurred()) + + gethTotalSupply := new(big.Int).SetBytes(gethStorage) + Expect(gethTotalSupply).To(Equal(erc20TotalSupply)) + + ipldStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract.Address), common.HexToHash(totalSupplyIndex), nil) + Expect(err).ToNot(HaveOccurred()) + Expect(gethStorage).To(Equal(ipldStorage)) + }) + + It("gets ERC20 total supply (with block number)", func() { + Expect(contractErr).ToNot(HaveOccurred()) + Expect(err).ToNot(Equal(false)) + + totalSupplyIndex := "0x2" + + gethStorage, err := gethClient.StorageAt(ctx, common.HexToAddress(contract.Address), common.HexToHash(totalSupplyIndex), big.NewInt(int64(contract.BlockNumber))) + Expect(err).ToNot(HaveOccurred()) + + gethTotalSupply := new(big.Int).SetBytes(gethStorage) + Expect(gethTotalSupply).To(Equal(erc20TotalSupply)) + + ipldStorage, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract.Address), common.HexToHash(totalSupplyIndex), big.NewInt(int64(contract.BlockNumber))) + Expect(err).ToNot(HaveOccurred()) + Expect(gethStorage).To(Equal(ipldStorage)) + }) + }) + Describe("Chain ID", func() { It("Check chain id", func() { gethChainId, err := gethClient.ChainID(ctx)