Skip to content
This repository has been archived by the owner on Nov 29, 2024. It is now read-only.

Commit

Permalink
feat(e2e): test passing
Browse files Browse the repository at this point in the history
  • Loading branch information
srdtrk committed Aug 4, 2024
1 parent 5e1621f commit e729a03
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 4 deletions.
68 changes: 68 additions & 0 deletions contracts/abi/SP1ICS07Tendermint.json
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,19 @@
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "misbehaviour",
"inputs": [
{
"name": "",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [],
"stateMutability": "pure"
},
{
"type": "function",
"name": "updateClient",
Expand All @@ -571,6 +584,19 @@
],
"stateMutability": "nonpayable"
},
{
"type": "function",
"name": "upgradeClient",
"inputs": [
{
"name": "",
"type": "bytes",
"internalType": "bytes"
}
],
"outputs": [],
"stateMutability": "pure"
},
{
"type": "error",
"name": "CannotHandleMisbehavior",
Expand Down Expand Up @@ -629,6 +655,11 @@
}
]
},
{
"type": "error",
"name": "FeatureNotSupported",
"inputs": []
},
{
"type": "error",
"name": "FrozenClientState",
Expand Down Expand Up @@ -682,6 +713,32 @@
}
]
},
{
"type": "error",
"name": "ProofHeightMismatch",
"inputs": [
{
"name": "expectedRevisionNumber",
"type": "uint64",
"internalType": "uint64"
},
{
"name": "expectedRevisionHeight",
"type": "uint64",
"internalType": "uint64"
},
{
"name": "actualRevisionNumber",
"type": "uint64",
"internalType": "uint64"
},
{
"name": "actualRevisionHeight",
"type": "uint64",
"internalType": "uint64"
}
]
},
{
"type": "error",
"name": "ProofIsInTheFuture",
Expand Down Expand Up @@ -772,6 +829,17 @@
}
]
},
{
"type": "error",
"name": "UnknownMembershipProofType",
"inputs": [
{
"name": "proofType",
"type": "uint8",
"internalType": "uint8"
}
]
},
{
"type": "error",
"name": "VerificationKeyMismatch",
Expand Down
2 changes: 1 addition & 1 deletion contracts/script/genesis.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"trustedClientState": "00000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000030000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000c000000000000000000000000000000000000000000000000000000000012754500000000000000000000000000000000000000000000000000000000001baf800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000673696d642d310000000000000000000000000000000000000000000000000000",
"trustedConsensusState": "0000000000000000000000000000000000000000000000000000000066ae7fc031b1f3ae9260a3822b2250607170f650fd0b336908ff4ef0b24a2c350a313d44fe08aef679640ba370fbe11d92d48b592a85c598f97edb73be99032cdc313c22",
"trustedConsensusState": "0000000000000000000000000000000000000000000000000000000066afad81234b002d78b03df426a7e156ffe511253e9f874ed7feccc14d8d0002b1deba3a3e100db17d609c05af9bb099133aeea97349259ce45c581128ac8ffb51662a5a",
"updateClientVkey": "0x00d8ae8feed5fd1f82dbf7862b219cd74c516e5d09ee5ec9024b439e95f5a3e2",
"membershipVkey": "0x001ae64fb3c0ac2e5a62e4941b26edf05798f0dc3417ae105e4bd1c443de6188",
"ucAndMembershipVkey": "0x008ddefe335385fdfe8e6eefcebe2f9519cb27e95afd392537657bb4525883f9"
Expand Down
16 changes: 16 additions & 0 deletions e2e/interchaintestv8/e2esuite/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@ func (s *TestSuite) GetEthAddressFromStdout(stdout string) string {
return matches[1]
}

// GetEvmEvent parses the logs in the given receipt and returns the first event that can be parsed
func GetEvmEvent[T any](receipt *ethtypes.Receipt, parseFn func(log ethtypes.Log) (*T, error)) (event *T, err error) {
for _, l := range receipt.Logs {
event, err = parseFn(*l)
if err == nil && event != nil {
break
}
}

if event == nil {
err = fmt.Errorf("event not found")
}

return
}

// GetTransactOpts returns a new TransactOpts with the given private key
func (s *TestSuite) GetTransactOpts(key *ecdsa.PrivateKey) *bind.TransactOpts {
chainIDStr, err := strconv.ParseInt(s.ChainA.Config().ChainID, 10, 64)
Expand Down
12 changes: 10 additions & 2 deletions e2e/interchaintestv8/sp1_ics07_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (

"github.com/strangelove-ventures/interchaintest/v8/chain/ethereum"
"github.com/strangelove-ventures/interchaintest/v8/ibc"
"github.com/strangelove-ventures/interchaintest/v8/testutil"

"github.com/srdtrk/sp1-ics07-tendermint/e2e/v8/e2esuite"
"github.com/srdtrk/sp1-ics07-tendermint/e2e/v8/operator"
Expand Down Expand Up @@ -165,9 +166,11 @@ func (s *SP1ICS07TendermintTestSuite) TestUpdateClientAndMembership() {

s.SetupSuite(ctx)

_, simd := s.ChainA, s.ChainB
eth, simd := s.ChainA, s.ChainB

s.Require().True(s.Run("Update and verify non-membership", func() {
s.Require().NoError(testutil.WaitForBlocks(ctx, 5, simd))

clientState, err := s.contract.GetClientState(nil)
s.Require().NoError(err)

Expand All @@ -176,6 +179,8 @@ func (s *SP1ICS07TendermintTestSuite) TestUpdateClientAndMembership() {
latestHeight, err := simd.Height(ctx)
s.Require().NoError(err)

s.Require().Greater(uint32(latestHeight), trustedHeight)

// This will be a non-membership proof since no packets have been sent
packetReceiptPath := ibchost.PacketReceiptPath(transfertypes.PortID, ibctesting.FirstChannelID, 1)
proofHeight, ucAndMemProof, err := operator.UpdateClientAndMembershipProof(
Expand All @@ -192,9 +197,12 @@ func (s *SP1ICS07TendermintTestSuite) TestUpdateClientAndMembership() {
Value: []byte(""),
}

_, err = s.contract.Membership(s.GetTransactOpts(s.key), msg)
tx, err := s.contract.Membership(s.GetTransactOpts(s.key), msg)
s.Require().NoError(err)

// wait until transaction is included in a block
_ = s.GetTxReciept(ctx, eth, tx.Hash())

clientState, err = s.contract.GetClientState(nil)
s.Require().NoError(err)

Expand Down
60 changes: 59 additions & 1 deletion e2e/interchaintestv8/types/sp1ics07tendermint/contract.go

Large diffs are not rendered by default.

0 comments on commit e729a03

Please sign in to comment.