forked from cerc-io/ipld-eth-server
Fix empty value when contract is deleted.
This commit is contained in:
@@ -15,6 +15,8 @@ fastify.get('/v1/deployContract', async (req, reply) => {
|
||||
const token = await GLDToken.deploy();
|
||||
await token.deployed();
|
||||
|
||||
console.log(`Deployed block ${token.deployTransaction.blockNumber}`)
|
||||
|
||||
return {
|
||||
address: token.address,
|
||||
txHash: token.deployTransaction.hash,
|
||||
@@ -31,6 +33,8 @@ fastify.get('/v1/destroyContract', async (req, reply) => {
|
||||
|
||||
await token.destroy();
|
||||
const blockNum = await hre.ethers.provider.getBlockNumber()
|
||||
console.log(`Destroyed block ${blockNum}`)
|
||||
|
||||
return {
|
||||
blockNumber: blockNum,
|
||||
}
|
||||
|
||||
+2
-3
@@ -15,9 +15,7 @@ type ContractDeployed struct {
|
||||
}
|
||||
|
||||
type ContractDestroyed struct {
|
||||
TransactionHash string `json:"txHash"`
|
||||
BlockNumber int64 `json:"blockNumber"`
|
||||
BlockHash string `json:"blockHash"`
|
||||
BlockNumber int64 `json:"blockNumber"`
|
||||
}
|
||||
|
||||
type Tx struct {
|
||||
@@ -56,6 +54,7 @@ func DestroyContract(addr string) (*ContractDestroyed, error) {
|
||||
}
|
||||
defer res.Body.Close()
|
||||
|
||||
fmt.Println(res.Body)
|
||||
var data ContractDestroyed
|
||||
decoder := json.NewDecoder(res.Body)
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package integration_test
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"math/big"
|
||||
"time"
|
||||
|
||||
@@ -317,6 +318,8 @@ var _ = Describe("Integration test", func() {
|
||||
contract, contractErr = integration.DeployContract()
|
||||
erc20TotalSupply, bigIntResult = new(big.Int).SetString("1000000000000000000000", 10)
|
||||
|
||||
fmt.Printf("Deployed address: %d\n", contract.BlockNumber)
|
||||
|
||||
time.Sleep(sleepInterval)
|
||||
})
|
||||
|
||||
@@ -393,7 +396,7 @@ var _ = Describe("Integration test", func() {
|
||||
Expect(gethStorage).To(Equal(ipldStorage))
|
||||
})
|
||||
|
||||
It("get storage after self destruct", func() {
|
||||
FIt("get storage after self destruct", func() {
|
||||
totalSupplyIndex := "0x2"
|
||||
|
||||
tx, err := integration.DestroyContract(contract.Address)
|
||||
@@ -401,6 +404,10 @@ var _ = Describe("Integration test", func() {
|
||||
|
||||
time.Sleep(sleepInterval)
|
||||
|
||||
fmt.Printf("Destroyed address: %d\n", tx.BlockNumber)
|
||||
|
||||
fmt.Printf("Contract Address: %s \n", contract.Address)
|
||||
|
||||
gethStorage1, err := gethClient.StorageAt(ctx, common.HexToAddress(contract.Address), common.HexToHash(totalSupplyIndex), big.NewInt(tx.BlockNumber-1))
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
gethStorage2, err := gethClient.StorageAt(ctx, common.HexToAddress(contract.Address), common.HexToHash(totalSupplyIndex), big.NewInt(tx.BlockNumber))
|
||||
@@ -416,6 +423,12 @@ var _ = Describe("Integration test", func() {
|
||||
|
||||
Expect(ipldStorage1).To(Equal(gethStorage1))
|
||||
Expect(ipldStorage2).To(Equal(gethStorage2))
|
||||
|
||||
// Query the current block
|
||||
ipldStorage3, err := ipldClient.StorageAt(ctx, common.HexToAddress(contract.Address), common.HexToHash(totalSupplyIndex), nil)
|
||||
Expect(err).ToNot(HaveOccurred())
|
||||
|
||||
Expect(ipldStorage2).To(Equal(ipldStorage3))
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user