diff --git a/pkg/eth/api_test.go b/pkg/eth/api_test.go index 70e3c4c8..076a7693 100644 --- a/pkg/eth/api_test.go +++ b/pkg/eth/api_test.go @@ -965,9 +965,10 @@ var _ = Describe("API", func() { Expect(err).ToNot(HaveOccurred()) Expect(code).To(Equal((hexutil.Bytes)(test_helpers.ContractCode))) }) - It("Throws an error for an account it cannot find the code for", func() { - _, err := api.GetCode(ctx, randomAddr, rpc.BlockNumberOrHashWithHash(blockHash, true)) - Expect(err).To(HaveOccurred()) + It("Returns `nil` for an account it cannot find the code for", func() { + code, err := api.GetCode(ctx, randomAddr, rpc.BlockNumberOrHashWithHash(blockHash, true)) + Expect(err).ToNot(HaveOccurred()) + Expect(code).To(BeEmpty()) }) }) }) diff --git a/pkg/eth/eth_state_test.go b/pkg/eth/eth_state_test.go index 79784951..2afc0d07 100644 --- a/pkg/eth/eth_state_test.go +++ b/pkg/eth/eth_state_test.go @@ -409,13 +409,15 @@ var _ = Describe("eth state reading tests", func() { Expect(err).ToNot(HaveOccurred()) Expect(code).To(Equal((hexutil.Bytes)(test_helpers.ContractCode))) }) - It("Throws an error for an account it cannot find the code for", func() { - _, err := api.GetCode(ctx, randomAddr, rpc.BlockNumberOrHashWithHash(blocks[3].Hash(), true)) - Expect(err).To(HaveOccurred()) + It("Returns `nil` for an account it cannot find the code for", func() { + code, err := api.GetCode(ctx, randomAddr, rpc.BlockNumberOrHashWithHash(blocks[3].Hash(), true)) + Expect(err).ToNot(HaveOccurred()) + Expect(code).To(BeEmpty()) }) - It("Throws an error for a contract that doesn't exist at this hieght", func() { - _, err := api.GetCode(ctx, test_helpers.ContractAddr, rpc.BlockNumberOrHashWithNumber(0)) - Expect(err).To(HaveOccurred()) + It("Returns `nil` for a contract that doesn't exist at this height", func() { + code, err := api.GetCode(ctx, test_helpers.ContractAddr, rpc.BlockNumberOrHashWithNumber(0)) + Expect(err).ToNot(HaveOccurred()) + Expect(code).To(BeEmpty()) }) }) diff --git a/test/integration_test.go b/test/integration_test.go index f434110a..ba4b41ce 100644 --- a/test/integration_test.go +++ b/test/integration_test.go @@ -204,7 +204,16 @@ var _ = Describe("Integration test", func() { ipldCode, err := ipldClient.CodeAt(ctx, common.HexToAddress(contract.Address), nil) Expect(err).ToNot(HaveOccurred()) + Expect(gethCode).To(Equal(ipldCode)) + }) + It("gets code of contract that doesn't exist at this height", func() { + gethCode, err := gethClient.CodeAt(ctx, common.HexToAddress(contract.Address), big.NewInt(int64(contract.BlockNumber-1))) + Expect(err).ToNot(HaveOccurred()) + ipldCode, err := ipldClient.CodeAt(ctx, common.HexToAddress(contract.Address), big.NewInt(int64(contract.BlockNumber-1))) + Expect(err).ToNot(HaveOccurred()) + + Expect(gethCode).To(BeEmpty()) Expect(gethCode).To(Equal(ipldCode)) }) })