From 549c18152c14171bff403a05878ef32da48cf665 Mon Sep 17 00:00:00 2001 From: Damian Nolan Date: Tue, 12 Jul 2022 14:54:00 +0100 Subject: [PATCH] chore: restructuring 07-tendermint lightclient directory layout (#1677) * restructuring 07-tendermint lightclient directory tree * adding changelog entry * chore: restructuring 06-solomachine lightclient directory layout (#1679) * restructing 06-solomachine folder layout * tidy go modules * fixing dead link * adding changelog entry --- CHANGELOG.md | 2 + go.mod | 2 +- go.sum | 4 +- modules/core/02-client/abci.go | 2 +- modules/core/02-client/abci_test.go | 2 +- modules/core/02-client/client/utils/utils.go | 2 +- modules/core/02-client/keeper/client_test.go | 4 +- .../core/02-client/keeper/grpc_query_test.go | 2 +- modules/core/02-client/keeper/keeper.go | 2 +- modules/core/02-client/keeper/keeper_test.go | 4 +- .../core/02-client/keeper/proposal_test.go | 2 +- modules/core/02-client/legacy/v100/genesis.go | 2 +- .../02-client/legacy/v100/genesis_test.go | 2 +- modules/core/02-client/legacy/v100/store.go | 4 +- .../core/02-client/legacy/v100/store_test.go | 4 +- .../core/02-client/proposal_handler_test.go | 2 +- .../core/02-client/simulation/decoder_test.go | 2 +- modules/core/02-client/types/codec_test.go | 2 +- modules/core/02-client/types/encoding_test.go | 2 +- modules/core/02-client/types/genesis_test.go | 4 +- modules/core/02-client/types/msgs_test.go | 4 +- modules/core/02-client/types/proposal_test.go | 2 +- .../03-connection/keeper/handshake_test.go | 2 +- .../core/03-connection/keeper/verify_test.go | 2 +- modules/core/03-connection/types/msgs_test.go | 2 +- modules/core/04-channel/keeper/packet_test.go | 2 +- modules/core/genesis_test.go | 2 +- modules/core/keeper/msg_server_test.go | 2 +- modules/core/simulation/decoder_test.go | 2 +- modules/core/types/codec.go | 4 +- .../{types => }/client_state.go | 2 +- .../{types => }/client_state_test.go | 254 +++++++++--------- .../06-solomachine/{types => }/codec.go | 2 +- .../06-solomachine/codec_test.go | 190 +++++++++++++ .../{types => }/consensus_state.go | 2 +- .../{types => }/consensus_state_test.go | 28 +- .../06-solomachine/{types => }/errors.go | 2 +- .../06-solomachine/{types => }/header.go | 2 +- .../06-solomachine/{types => }/header_test.go | 20 +- .../{types => }/misbehaviour.go | 2 +- .../{types => }/misbehaviour_handle.go | 2 +- .../{types => }/misbehaviour_test.go | 40 +-- .../light-clients/06-solomachine/module.go | 6 +- .../06-solomachine/{types => }/proof.go | 2 +- .../06-solomachine/{types => }/proof_test.go | 27 +- .../{types => }/proposal_handle.go | 2 +- .../{types => }/proposal_handle_test.go | 24 +- .../06-solomachine/{types => }/solomachine.go | 2 +- .../{types => }/solomachine.pb.go | 36 +-- .../{types => }/solomachine_test.go | 19 +- .../06-solomachine/spec/01_concepts.md | 6 +- .../06-solomachine/types/codec_test.go | 190 ------------- .../06-solomachine/{types => }/update.go | 2 +- .../06-solomachine/{types => }/update_test.go | 180 ++++++------- .../07-tendermint/{types => }/client_state.go | 2 +- .../{types => }/client_state_test.go | 48 ++-- .../07-tendermint/{types => }/codec.go | 2 +- .../{types => }/consensus_state.go | 2 +- .../{types => }/consensus_state_test.go | 20 +- .../07-tendermint/{types => }/errors.go | 2 +- .../07-tendermint/{types => }/fraction.go | 2 +- .../07-tendermint/{types => }/genesis.go | 2 +- .../07-tendermint/{types => }/genesis_test.go | 34 +-- .../07-tendermint/{types => }/header.go | 2 +- .../07-tendermint/{types => }/header_test.go | 6 +- .../07-tendermint/{types => }/misbehaviour.go | 2 +- .../{types => }/misbehaviour_handle.go | 2 +- .../{types => }/misbehaviour_handle_test.go | 72 ++--- .../{types => }/misbehaviour_test.go | 70 ++--- modules/light-clients/07-tendermint/module.go | 6 +- .../{types => }/proposal_handle.go | 8 +- .../{types => }/proposal_handle_test.go | 40 +-- .../07-tendermint/{types => }/store.go | 2 +- .../07-tendermint/{types => }/store_test.go | 66 ++--- .../{types => }/tendermint.pb.go | 140 +++++----- .../{types => }/tendermint_test.go | 6 +- .../07-tendermint/{types => }/update.go | 2 +- .../07-tendermint/{types => }/update_test.go | 65 +++-- .../07-tendermint/{types => }/upgrade.go | 2 +- .../07-tendermint/{types => }/upgrade_test.go | 24 +- .../solomachine/v2/solomachine.proto | 2 +- .../tendermint/v1/tendermint.proto | 2 +- testing/chain.go | 2 +- testing/config.go | 2 +- testing/endpoint.go | 2 +- testing/solomachine.go | 2 +- testing/values.go | 2 +- 87 files changed, 876 insertions(+), 885 deletions(-) rename modules/light-clients/06-solomachine/{types => }/client_state.go (99%) rename modules/light-clients/06-solomachine/{types => }/client_state_test.go (69%) rename modules/light-clients/06-solomachine/{types => }/codec.go (99%) create mode 100644 modules/light-clients/06-solomachine/codec_test.go rename modules/light-clients/06-solomachine/{types => }/consensus_state.go (98%) rename modules/light-clients/06-solomachine/{types => }/consensus_state_test.go (64%) rename modules/light-clients/06-solomachine/{types => }/errors.go (97%) rename modules/light-clients/06-solomachine/{types => }/header.go (98%) rename modules/light-clients/06-solomachine/{types => }/header_test.go (83%) rename modules/light-clients/06-solomachine/{types => }/misbehaviour.go (99%) rename modules/light-clients/06-solomachine/{types => }/misbehaviour_handle.go (98%) rename modules/light-clients/06-solomachine/{types => }/misbehaviour_test.go (65%) rename modules/light-clients/06-solomachine/{types => }/proof.go (99%) rename modules/light-clients/06-solomachine/{types => }/proof_test.go (57%) rename modules/light-clients/06-solomachine/{types => }/proposal_handle.go (99%) rename modules/light-clients/06-solomachine/{types => }/proposal_handle_test.go (71%) rename modules/light-clients/06-solomachine/{types => }/solomachine.go (98%) rename modules/light-clients/06-solomachine/{types => }/solomachine.pb.go (98%) rename modules/light-clients/06-solomachine/{types => }/solomachine_test.go (85%) delete mode 100644 modules/light-clients/06-solomachine/types/codec_test.go rename modules/light-clients/06-solomachine/{types => }/update.go (99%) rename modules/light-clients/06-solomachine/{types => }/update_test.go (66%) rename modules/light-clients/07-tendermint/{types => }/client_state.go (99%) rename modules/light-clients/07-tendermint/{types => }/client_state_test.go (86%) rename modules/light-clients/07-tendermint/{types => }/codec.go (97%) rename modules/light-clients/07-tendermint/{types => }/consensus_state.go (99%) rename modules/light-clients/07-tendermint/{types => }/consensus_state_test.go (81%) rename modules/light-clients/07-tendermint/{types => }/errors.go (98%) rename modules/light-clients/07-tendermint/{types => }/fraction.go (97%) rename modules/light-clients/07-tendermint/{types => }/genesis.go (97%) rename modules/light-clients/07-tendermint/{types => }/genesis_test.go (67%) rename modules/light-clients/07-tendermint/{types => }/header.go (99%) rename modules/light-clients/07-tendermint/{types => }/header_test.go (94%) rename modules/light-clients/07-tendermint/{types => }/misbehaviour.go (99%) rename modules/light-clients/07-tendermint/{types => }/misbehaviour_handle.go (99%) rename modules/light-clients/07-tendermint/{types => }/misbehaviour_handle_test.go (95%) rename modules/light-clients/07-tendermint/{types => }/misbehaviour_test.go (81%) rename modules/light-clients/07-tendermint/{types => }/proposal_handle.go (97%) rename modules/light-clients/07-tendermint/{types => }/proposal_handle_test.go (86%) rename modules/light-clients/07-tendermint/{types => }/store.go (99%) rename modules/light-clients/07-tendermint/{types => }/store_test.go (64%) rename modules/light-clients/07-tendermint/{types => }/tendermint.pb.go (87%) rename modules/light-clients/07-tendermint/{types => }/tendermint_test.go (96%) rename modules/light-clients/07-tendermint/{types => }/update.go (99%) rename modules/light-clients/07-tendermint/{types => }/update_test.go (93%) rename modules/light-clients/07-tendermint/{types => }/upgrade.go (99%) rename modules/light-clients/07-tendermint/{types => }/upgrade_test.go (93%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 57ffd0946a1..e9c0c464864 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -43,6 +43,8 @@ Ref: https://keepachangelog.com/en/1.0.0/ ### API Breaking * (transfer) [\#1250](https://github.com/cosmos/ibc-go/pull/1250) Deprecate `GetTransferAccount` since the `transfer` module account is never used. +* (06-solomachine) [\#1679](https://github.com/cosmos/ibc-go/pull/1679) Remove `types` sub-package from `06-solomachine` lightclient directory. +* (07-tendermint) [\#1677](https://github.com/cosmos/ibc-go/pull/1677) Remove `types` sub-package from `07-tendermint` lightclient directory. ### State Machine Breaking diff --git a/go.mod b/go.mod index 4f56c03dd9e..225f608d60f 100644 --- a/go.mod +++ b/go.mod @@ -7,7 +7,7 @@ replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alp require ( github.com/armon/go-metrics v0.3.10 github.com/confio/ics23/go v0.7.0 - github.com/cosmos/cosmos-sdk v0.45.3 + github.com/cosmos/cosmos-sdk v0.45.4 github.com/gogo/protobuf v1.3.3 github.com/golang/protobuf v1.5.2 github.com/gorilla/mux v1.8.0 diff --git a/go.sum b/go.sum index a8f6d150085..5a51d87749c 100644 --- a/go.sum +++ b/go.sum @@ -229,8 +229,8 @@ github.com/coreos/pkg v0.0.0-20160727233714-3ac0863d7acf/go.mod h1:E3G3o1h8I7cfc github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA= github.com/cosmos/btcutil v1.0.4 h1:n7C2ngKXo7UC9gNyMNLbzqz7Asuf+7Qv4gnX/rOdQ44= github.com/cosmos/btcutil v1.0.4/go.mod h1:Ffqc8Hn6TJUdDgHBwIZLtrLQC1KdJ9jGJl/TvgUaxbU= -github.com/cosmos/cosmos-sdk v0.45.3 h1:PiVSU3IkNEDPhoxOZHk2lPnhwBBJgEYAtAR0jGXRN4g= -github.com/cosmos/cosmos-sdk v0.45.3/go.mod h1:qYm5JEr0ZlbnmoP/Q3b+dYMOliHf4ddHirpILiwZzqg= +github.com/cosmos/cosmos-sdk v0.45.4 h1:eStDAhJdMY8n5arbBRe+OwpNeBSunxSBHp1g55ulfdA= +github.com/cosmos/cosmos-sdk v0.45.4/go.mod h1:WOqtDxN3eCCmnYLVla10xG7lEXkFjpTaqm2a2WasgCc= github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y= github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY= github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw= diff --git a/modules/core/02-client/abci.go b/modules/core/02-client/abci.go index ec209b4fdd0..f32fd129309 100644 --- a/modules/core/02-client/abci.go +++ b/modules/core/02-client/abci.go @@ -4,7 +4,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/ibc-go/v3/modules/core/02-client/keeper" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ) // BeginBlocker is used to perform IBC client upgrades diff --git a/modules/core/02-client/abci_test.go b/modules/core/02-client/abci_test.go index 5d220f53a42..16aee80088a 100644 --- a/modules/core/02-client/abci_test.go +++ b/modules/core/02-client/abci_test.go @@ -10,7 +10,7 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" client "github.com/cosmos/ibc-go/v3/modules/core/02-client" "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) diff --git a/modules/core/02-client/client/utils/utils.go b/modules/core/02-client/client/utils/utils.go index a596ff61410..0ea44d7523b 100644 --- a/modules/core/02-client/client/utils/utils.go +++ b/modules/core/02-client/client/utils/utils.go @@ -13,7 +13,7 @@ import ( host "github.com/cosmos/ibc-go/v3/modules/core/24-host" ibcclient "github.com/cosmos/ibc-go/v3/modules/core/client" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ) // QueryClientState returns a client state. If prove is true, it performs an ABCI store query diff --git a/modules/core/02-client/keeper/client_test.go b/modules/core/02-client/keeper/client_test.go index 3f52359c62c..504eca3f726 100644 --- a/modules/core/02-client/keeper/client_test.go +++ b/modules/core/02-client/keeper/client_test.go @@ -11,8 +11,8 @@ import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) diff --git a/modules/core/02-client/keeper/grpc_query_test.go b/modules/core/02-client/keeper/grpc_query_test.go index 60a5211733a..af8183bc5de 100644 --- a/modules/core/02-client/keeper/grpc_query_test.go +++ b/modules/core/02-client/keeper/grpc_query_test.go @@ -13,7 +13,7 @@ import ( "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) diff --git a/modules/core/02-client/keeper/keeper.go b/modules/core/02-client/keeper/keeper.go index 74a043e9dea..1d32549654a 100644 --- a/modules/core/02-client/keeper/keeper.go +++ b/modules/core/02-client/keeper/keeper.go @@ -18,7 +18,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ) // Keeper represents a type that grants read and write permissions to any client diff --git a/modules/core/02-client/keeper/keeper_test.go b/modules/core/02-client/keeper/keeper_test.go index 83e017dd8a4..00bcfda178e 100644 --- a/modules/core/02-client/keeper/keeper_test.go +++ b/modules/core/02-client/keeper/keeper_test.go @@ -19,8 +19,8 @@ import ( "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibctestingmock "github.com/cosmos/ibc-go/v3/testing/mock" "github.com/cosmos/ibc-go/v3/testing/simapp" diff --git a/modules/core/02-client/keeper/proposal_test.go b/modules/core/02-client/keeper/proposal_test.go index 0fbef636305..0dcd123f06e 100644 --- a/modules/core/02-client/keeper/proposal_test.go +++ b/modules/core/02-client/keeper/proposal_test.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) diff --git a/modules/core/02-client/legacy/v100/genesis.go b/modules/core/02-client/legacy/v100/genesis.go index fa052ade3f8..507443382a5 100644 --- a/modules/core/02-client/legacy/v100/genesis.go +++ b/modules/core/02-client/legacy/v100/genesis.go @@ -10,7 +10,7 @@ import ( "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ) // MigrateGenesis accepts exported v1.0.0 IBC client genesis file and migrates it to: diff --git a/modules/core/02-client/legacy/v100/genesis_test.go b/modules/core/02-client/legacy/v100/genesis_test.go index 4835ce98213..0c64722bc59 100644 --- a/modules/core/02-client/legacy/v100/genesis_test.go +++ b/modules/core/02-client/legacy/v100/genesis_test.go @@ -14,7 +14,7 @@ import ( "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" "github.com/cosmos/ibc-go/v3/testing/simapp" ) diff --git a/modules/core/02-client/legacy/v100/store.go b/modules/core/02-client/legacy/v100/store.go index f92aa224676..08910ea419a 100644 --- a/modules/core/02-client/legacy/v100/store.go +++ b/modules/core/02-client/legacy/v100/store.go @@ -14,8 +14,8 @@ import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - smtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + smtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ) // MigrateStore performs in-place store migrations from SDK v0.40 of the IBC module to v1.0.0 of ibc-go. diff --git a/modules/core/02-client/legacy/v100/store_test.go b/modules/core/02-client/legacy/v100/store_test.go index a1c1be3034a..db06d7d4cbd 100644 --- a/modules/core/02-client/legacy/v100/store_test.go +++ b/modules/core/02-client/legacy/v100/store_test.go @@ -6,11 +6,11 @@ import ( "github.com/stretchr/testify/suite" - "github.com/cosmos/ibc-go/v3/modules/core/02-client/legacy/v100" + v100 "github.com/cosmos/ibc-go/v3/modules/core/02-client/legacy/v100" "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) diff --git a/modules/core/02-client/proposal_handler_test.go b/modules/core/02-client/proposal_handler_test.go index 4ef2798d633..2e510f8777e 100644 --- a/modules/core/02-client/proposal_handler_test.go +++ b/modules/core/02-client/proposal_handler_test.go @@ -7,7 +7,7 @@ import ( client "github.com/cosmos/ibc-go/v3/modules/core/02-client" clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) diff --git a/modules/core/02-client/simulation/decoder_test.go b/modules/core/02-client/simulation/decoder_test.go index 0e106614f64..962435a7e25 100644 --- a/modules/core/02-client/simulation/decoder_test.go +++ b/modules/core/02-client/simulation/decoder_test.go @@ -11,7 +11,7 @@ import ( "github.com/cosmos/ibc-go/v3/modules/core/02-client/simulation" "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" "github.com/cosmos/ibc-go/v3/testing/simapp" ) diff --git a/modules/core/02-client/types/codec_test.go b/modules/core/02-client/types/codec_test.go index 7ff2455f507..2db68dbb244 100644 --- a/modules/core/02-client/types/codec_test.go +++ b/modules/core/02-client/types/codec_test.go @@ -6,7 +6,7 @@ import ( "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) diff --git a/modules/core/02-client/types/encoding_test.go b/modules/core/02-client/types/encoding_test.go index efc4f85aad3..e1846c39f25 100644 --- a/modules/core/02-client/types/encoding_test.go +++ b/modules/core/02-client/types/encoding_test.go @@ -2,7 +2,7 @@ package types_test import ( "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ) func (suite *TypesTestSuite) TestMarshalHeader() { diff --git a/modules/core/02-client/types/genesis_test.go b/modules/core/02-client/types/genesis_test.go index 8dac1291172..3774ff48800 100644 --- a/modules/core/02-client/types/genesis_test.go +++ b/modules/core/02-client/types/genesis_test.go @@ -9,8 +9,8 @@ import ( "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibctestingmock "github.com/cosmos/ibc-go/v3/testing/mock" ) diff --git a/modules/core/02-client/types/msgs_test.go b/modules/core/02-client/types/msgs_test.go index ee5bed3cfb8..c51ebfce957 100644 --- a/modules/core/02-client/types/msgs_test.go +++ b/modules/core/02-client/types/msgs_test.go @@ -9,8 +9,8 @@ import ( "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" - solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) diff --git a/modules/core/02-client/types/proposal_test.go b/modules/core/02-client/types/proposal_test.go index ad5be469961..8ef103ee18a 100644 --- a/modules/core/02-client/types/proposal_test.go +++ b/modules/core/02-client/types/proposal_test.go @@ -9,7 +9,7 @@ import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) diff --git a/modules/core/03-connection/keeper/handshake_test.go b/modules/core/03-connection/keeper/handshake_test.go index 6f5dfbce1d9..316c82023ee 100644 --- a/modules/core/03-connection/keeper/handshake_test.go +++ b/modules/core/03-connection/keeper/handshake_test.go @@ -7,7 +7,7 @@ import ( "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) diff --git a/modules/core/03-connection/keeper/verify_test.go b/modules/core/03-connection/keeper/verify_test.go index 520dfed1397..f6fc1f92c19 100644 --- a/modules/core/03-connection/keeper/verify_test.go +++ b/modules/core/03-connection/keeper/verify_test.go @@ -9,7 +9,7 @@ import ( channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" ) diff --git a/modules/core/03-connection/types/msgs_test.go b/modules/core/03-connection/types/msgs_test.go index 9cf741bb2c0..871da3c2b9c 100644 --- a/modules/core/03-connection/types/msgs_test.go +++ b/modules/core/03-connection/types/msgs_test.go @@ -15,7 +15,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types" commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" "github.com/cosmos/ibc-go/v3/testing/simapp" ) diff --git a/modules/core/04-channel/keeper/packet_test.go b/modules/core/04-channel/keeper/packet_test.go index 66bc6846450..949b45a2e2f 100644 --- a/modules/core/04-channel/keeper/packet_test.go +++ b/modules/core/04-channel/keeper/packet_test.go @@ -12,7 +12,7 @@ import ( "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" ) diff --git a/modules/core/genesis_test.go b/modules/core/genesis_test.go index f45d70a8eca..e27f44cf5bd 100644 --- a/modules/core/genesis_test.go +++ b/modules/core/genesis_test.go @@ -15,7 +15,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" "github.com/cosmos/ibc-go/v3/modules/core/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" "github.com/cosmos/ibc-go/v3/testing/simapp" ) diff --git a/modules/core/keeper/msg_server_test.go b/modules/core/keeper/msg_server_test.go index f61e2efd5a8..f4d0a05282f 100644 --- a/modules/core/keeper/msg_server_test.go +++ b/modules/core/keeper/msg_server_test.go @@ -13,7 +13,7 @@ import ( host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" "github.com/cosmos/ibc-go/v3/modules/core/keeper" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" ) diff --git a/modules/core/simulation/decoder_test.go b/modules/core/simulation/decoder_test.go index 6639c96b8e4..621375a024f 100644 --- a/modules/core/simulation/decoder_test.go +++ b/modules/core/simulation/decoder_test.go @@ -12,7 +12,7 @@ import ( channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/simulation" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" "github.com/cosmos/ibc-go/v3/testing/simapp" ) diff --git a/modules/core/types/codec.go b/modules/core/types/codec.go index 8069c76715e..079fa341d25 100644 --- a/modules/core/types/codec.go +++ b/modules/core/types/codec.go @@ -7,8 +7,8 @@ import ( connectiontypes "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" - solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ) // RegisterInterfaces registers x/ibc interfaces into protobuf Any. diff --git a/modules/light-clients/06-solomachine/types/client_state.go b/modules/light-clients/06-solomachine/client_state.go similarity index 99% rename from modules/light-clients/06-solomachine/types/client_state.go rename to modules/light-clients/06-solomachine/client_state.go index 06dbccb6e64..b985bbcf3be 100644 --- a/modules/light-clients/06-solomachine/types/client_state.go +++ b/modules/light-clients/06-solomachine/client_state.go @@ -1,4 +1,4 @@ -package types +package solomachine import ( "reflect" diff --git a/modules/light-clients/06-solomachine/types/client_state_test.go b/modules/light-clients/06-solomachine/client_state_test.go similarity index 69% rename from modules/light-clients/06-solomachine/types/client_state_test.go rename to modules/light-clients/06-solomachine/client_state_test.go index 3e0c4904b7b..ab1d7c66a08 100644 --- a/modules/light-clients/06-solomachine/types/client_state_test.go +++ b/modules/light-clients/06-solomachine/client_state_test.go @@ -1,4 +1,4 @@ -package types_test +package solomachine_test import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" @@ -6,8 +6,8 @@ import ( channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + solomachine "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) @@ -39,41 +39,41 @@ func (suite *SoloMachineTestSuite) TestStatus() { func (suite *SoloMachineTestSuite) TestClientStateValidateBasic() { // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { testCases := []struct { name string - clientState *types.ClientState + clientState *solomachine.ClientState expPass bool }{ { "valid client state", - solomachine.ClientState(), + sm.ClientState(), true, }, { "empty ClientState", - &types.ClientState{}, + &solomachine.ClientState{}, false, }, { "sequence is zero", - types.NewClientState(0, &types.ConsensusState{solomachine.ConsensusState().PublicKey, solomachine.Diversifier, solomachine.Time}, false), + solomachine.NewClientState(0, &solomachine.ConsensusState{sm.ConsensusState().PublicKey, sm.Diversifier, sm.Time}, false), false, }, { "timestamp is zero", - types.NewClientState(1, &types.ConsensusState{solomachine.ConsensusState().PublicKey, solomachine.Diversifier, 0}, false), + solomachine.NewClientState(1, &solomachine.ConsensusState{sm.ConsensusState().PublicKey, sm.Diversifier, 0}, false), false, }, { "diversifier is blank", - types.NewClientState(1, &types.ConsensusState{solomachine.ConsensusState().PublicKey, " ", 1}, false), + solomachine.NewClientState(1, &solomachine.ConsensusState{sm.ConsensusState().PublicKey, " ", 1}, false), false, }, { "pubkey is empty", - types.NewClientState(1, &types.ConsensusState{nil, solomachine.Diversifier, solomachine.Time}, false), + solomachine.NewClientState(1, &solomachine.ConsensusState{nil, sm.Diversifier, sm.Time}, false), false, }, } @@ -97,8 +97,8 @@ func (suite *SoloMachineTestSuite) TestClientStateValidateBasic() { func (suite *SoloMachineTestSuite) TestInitialize() { // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { - malleatedConsensus := solomachine.ClientState().ConsensusState + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + malleatedConsensus := sm.ClientState().ConsensusState malleatedConsensus.Timestamp = malleatedConsensus.Timestamp + 10 testCases := []struct { @@ -108,7 +108,7 @@ func (suite *SoloMachineTestSuite) TestInitialize() { }{ { "valid consensus state", - solomachine.ConsensusState(), + sm.ConsensusState(), true, }, { @@ -129,7 +129,7 @@ func (suite *SoloMachineTestSuite) TestInitialize() { } for _, tc := range testCases { - err := solomachine.ClientState().Initialize( + err := sm.ClientState().Initialize( suite.chainA.GetContext(), suite.chainA.Codec, suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "solomachine"), tc.consState, @@ -152,16 +152,16 @@ func (suite *SoloMachineTestSuite) TestVerifyClientState() { path := suite.solomachine.GetClientStatePath(counterpartyClientIdentifier) // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { - value, err := types.ClientStateSignBytes(suite.chainA.Codec, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path, clientState) + value, err := solomachine.ClientStateSignBytes(suite.chainA.Codec, sm.Sequence, sm.Time, sm.Diversifier, path, clientState) suite.Require().NoError(err) - sig := solomachine.GenerateSignature(value) + sig := sm.GenerateSignature(value) - signatureDoc := &types.TimestampedSignatureData{ + signatureDoc := &solomachine.TimestampedSignatureData{ SignatureData: sig, - Timestamp: solomachine.Time, + Timestamp: sm.Time, } proof, err := suite.chainA.Codec.Marshal(signatureDoc) @@ -169,38 +169,38 @@ func (suite *SoloMachineTestSuite) TestVerifyClientState() { testCases := []struct { name string - clientState *types.ClientState + clientState *solomachine.ClientState prefix exported.Prefix proof []byte expPass bool }{ { "successful verification", - solomachine.ClientState(), + sm.ClientState(), prefix, proof, true, }, { "ApplyPrefix failed", - solomachine.ClientState(), + sm.ClientState(), nil, proof, false, }, { "consensus state in client state is nil", - types.NewClientState(1, nil, false), + solomachine.NewClientState(1, nil, false), prefix, proof, false, }, { "client state latest height is less than sequence", - types.NewClientState(solomachine.Sequence-1, - &types.ConsensusState{ - Timestamp: solomachine.Time, - PublicKey: solomachine.ConsensusState().PublicKey, + solomachine.NewClientState(sm.Sequence-1, + &solomachine.ConsensusState{ + Timestamp: sm.Time, + PublicKey: sm.ConsensusState().PublicKey, }, false), prefix, proof, @@ -208,10 +208,10 @@ func (suite *SoloMachineTestSuite) TestVerifyClientState() { }, { "consensus state timestamp is greater than signature", - types.NewClientState(solomachine.Sequence, - &types.ConsensusState{ - Timestamp: solomachine.Time + 1, - PublicKey: solomachine.ConsensusState().PublicKey, + solomachine.NewClientState(sm.Sequence, + &solomachine.ConsensusState{ + Timestamp: sm.Time + 1, + PublicKey: sm.ConsensusState().PublicKey, }, false), prefix, proof, @@ -220,14 +220,14 @@ func (suite *SoloMachineTestSuite) TestVerifyClientState() { { "proof is nil", - solomachine.ClientState(), + sm.ClientState(), prefix, nil, false, }, { "proof verification failed", - solomachine.ClientState(), + sm.ClientState(), prefix, suite.GetInvalidProof(), false, @@ -245,7 +245,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientState() { } // NOTE: to replicate the ordering of connection handshake, we must decrement proof height by 1 - height := clienttypes.NewHeight(solomachine.GetHeight().GetRevisionNumber(), solomachine.GetHeight().GetRevisionHeight()-1) + height := clienttypes.NewHeight(sm.GetHeight().GetRevisionNumber(), sm.GetHeight().GetRevisionHeight()-1) err := tc.clientState.VerifyClientState( suite.store, suite.chainA.Codec, height, tc.prefix, counterpartyClientIdentifier, tc.proof, clientState, @@ -274,15 +274,15 @@ func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() { path := suite.solomachine.GetConsensusStatePath(counterpartyClientIdentifier, consensusHeight) // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { - value, err := types.ConsensusStateSignBytes(suite.chainA.Codec, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path, consensusState) + value, err := solomachine.ConsensusStateSignBytes(suite.chainA.Codec, sm.Sequence, sm.Time, sm.Diversifier, path, consensusState) suite.Require().NoError(err) - sig := solomachine.GenerateSignature(value) - signatureDoc := &types.TimestampedSignatureData{ + sig := sm.GenerateSignature(value) + signatureDoc := &solomachine.TimestampedSignatureData{ SignatureData: sig, - Timestamp: solomachine.Time, + Timestamp: sm.Time, } proof, err := suite.chainA.Codec.Marshal(signatureDoc) @@ -290,38 +290,38 @@ func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() { testCases := []struct { name string - clientState *types.ClientState + clientState *solomachine.ClientState prefix exported.Prefix proof []byte expPass bool }{ { "successful verification", - solomachine.ClientState(), + sm.ClientState(), prefix, proof, true, }, { "ApplyPrefix failed", - solomachine.ClientState(), + sm.ClientState(), nil, proof, false, }, { "consensus state in client state is nil", - types.NewClientState(1, nil, false), + solomachine.NewClientState(1, nil, false), prefix, proof, false, }, { "client state latest height is less than sequence", - types.NewClientState(solomachine.Sequence-1, - &types.ConsensusState{ - Timestamp: solomachine.Time, - PublicKey: solomachine.ConsensusState().PublicKey, + solomachine.NewClientState(sm.Sequence-1, + &solomachine.ConsensusState{ + Timestamp: sm.Time, + PublicKey: sm.ConsensusState().PublicKey, }, false), prefix, proof, @@ -329,10 +329,10 @@ func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() { }, { "consensus state timestamp is greater than signature", - types.NewClientState(solomachine.Sequence, - &types.ConsensusState{ - Timestamp: solomachine.Time + 1, - PublicKey: solomachine.ConsensusState().PublicKey, + solomachine.NewClientState(sm.Sequence, + &solomachine.ConsensusState{ + Timestamp: sm.Time + 1, + PublicKey: sm.ConsensusState().PublicKey, }, false), prefix, proof, @@ -341,14 +341,14 @@ func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() { { "proof is nil", - solomachine.ClientState(), + sm.ClientState(), prefix, nil, false, }, { "proof verification failed", - solomachine.ClientState(), + sm.ClientState(), prefix, suite.GetInvalidProof(), false, @@ -366,7 +366,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientConsensusState() { } // NOTE: to replicate the ordering of connection handshake, we must decrement proof height by 1 - height := clienttypes.NewHeight(solomachine.GetHeight().GetRevisionNumber(), solomachine.GetHeight().GetRevisionHeight()-2) + height := clienttypes.NewHeight(sm.GetHeight().GetRevisionNumber(), sm.GetHeight().GetRevisionHeight()-2) err := tc.clientState.VerifyClientConsensusState( suite.store, suite.chainA.Codec, height, counterpartyClientIdentifier, consensusHeight, tc.prefix, tc.proof, consensusState, @@ -391,15 +391,15 @@ func (suite *SoloMachineTestSuite) TestVerifyConnectionState() { path := suite.solomachine.GetConnectionStatePath(testConnectionID) // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { - value, err := types.ConnectionStateSignBytes(suite.chainA.Codec, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path, conn) + value, err := solomachine.ConnectionStateSignBytes(suite.chainA.Codec, sm.Sequence, sm.Time, sm.Diversifier, path, conn) suite.Require().NoError(err) - sig := solomachine.GenerateSignature(value) - signatureDoc := &types.TimestampedSignatureData{ + sig := sm.GenerateSignature(value) + signatureDoc := &solomachine.TimestampedSignatureData{ SignatureData: sig, - Timestamp: solomachine.Time, + Timestamp: sm.Time, } proof, err := suite.chainA.Codec.Marshal(signatureDoc) @@ -407,35 +407,35 @@ func (suite *SoloMachineTestSuite) TestVerifyConnectionState() { testCases := []struct { name string - clientState *types.ClientState + clientState *solomachine.ClientState prefix exported.Prefix proof []byte expPass bool }{ { "successful verification", - solomachine.ClientState(), + sm.ClientState(), prefix, proof, true, }, { "ApplyPrefix failed", - solomachine.ClientState(), + sm.ClientState(), commitmenttypes.NewMerklePrefix([]byte{}), proof, false, }, { "proof is nil", - solomachine.ClientState(), + sm.ClientState(), prefix, nil, false, }, { "proof verification failed", - solomachine.ClientState(), + sm.ClientState(), prefix, suite.GetInvalidProof(), false, @@ -448,7 +448,7 @@ func (suite *SoloMachineTestSuite) TestVerifyConnectionState() { expSeq := tc.clientState.Sequence + 1 err := tc.clientState.VerifyConnectionState( - suite.store, suite.chainA.Codec, solomachine.GetHeight(), tc.prefix, tc.proof, testConnectionID, conn, + suite.store, suite.chainA.Codec, sm.GetHeight(), tc.prefix, tc.proof, testConnectionID, conn, ) if tc.expPass { @@ -469,15 +469,15 @@ func (suite *SoloMachineTestSuite) TestVerifyChannelState() { path := suite.solomachine.GetChannelStatePath(testPortID, testChannelID) // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { - value, err := types.ChannelStateSignBytes(suite.chainA.Codec, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path, ch) + value, err := solomachine.ChannelStateSignBytes(suite.chainA.Codec, sm.Sequence, sm.Time, sm.Diversifier, path, ch) suite.Require().NoError(err) - sig := solomachine.GenerateSignature(value) - signatureDoc := &types.TimestampedSignatureData{ + sig := sm.GenerateSignature(value) + signatureDoc := &solomachine.TimestampedSignatureData{ SignatureData: sig, - Timestamp: solomachine.Time, + Timestamp: sm.Time, } proof, err := suite.chainA.Codec.Marshal(signatureDoc) @@ -485,35 +485,35 @@ func (suite *SoloMachineTestSuite) TestVerifyChannelState() { testCases := []struct { name string - clientState *types.ClientState + clientState *solomachine.ClientState prefix exported.Prefix proof []byte expPass bool }{ { "successful verification", - solomachine.ClientState(), + sm.ClientState(), prefix, proof, true, }, { "ApplyPrefix failed", - solomachine.ClientState(), + sm.ClientState(), nil, proof, false, }, { "proof is nil", - solomachine.ClientState(), + sm.ClientState(), prefix, nil, false, }, { "proof verification failed", - solomachine.ClientState(), + sm.ClientState(), prefix, suite.GetInvalidProof(), false, @@ -526,7 +526,7 @@ func (suite *SoloMachineTestSuite) TestVerifyChannelState() { expSeq := tc.clientState.Sequence + 1 err := tc.clientState.VerifyChannelState( - suite.store, suite.chainA.Codec, solomachine.GetHeight(), tc.prefix, tc.proof, testPortID, testChannelID, ch, + suite.store, suite.chainA.Codec, sm.GetHeight(), tc.prefix, tc.proof, testPortID, testChannelID, ch, ) if tc.expPass { @@ -544,17 +544,17 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketCommitment() { commitmentBytes := []byte("COMMITMENT BYTES") // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { - path := solomachine.GetPacketCommitmentPath(testPortID, testChannelID) + path := sm.GetPacketCommitmentPath(testPortID, testChannelID) - value, err := types.PacketCommitmentSignBytes(suite.chainA.Codec, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path, commitmentBytes) + value, err := solomachine.PacketCommitmentSignBytes(suite.chainA.Codec, sm.Sequence, sm.Time, sm.Diversifier, path, commitmentBytes) suite.Require().NoError(err) - sig := solomachine.GenerateSignature(value) - signatureDoc := &types.TimestampedSignatureData{ + sig := sm.GenerateSignature(value) + signatureDoc := &solomachine.TimestampedSignatureData{ SignatureData: sig, - Timestamp: solomachine.Time, + Timestamp: sm.Time, } proof, err := suite.chainA.Codec.Marshal(signatureDoc) @@ -562,35 +562,35 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketCommitment() { testCases := []struct { name string - clientState *types.ClientState + clientState *solomachine.ClientState prefix exported.Prefix proof []byte expPass bool }{ { "successful verification", - solomachine.ClientState(), + sm.ClientState(), prefix, proof, true, }, { "ApplyPrefix failed", - solomachine.ClientState(), + sm.ClientState(), commitmenttypes.NewMerklePrefix([]byte{}), proof, false, }, { "proof is nil", - solomachine.ClientState(), + sm.ClientState(), prefix, nil, false, }, { "proof verification failed", - solomachine.ClientState(), + sm.ClientState(), prefix, suite.GetInvalidProof(), false, @@ -604,7 +604,7 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketCommitment() { ctx := suite.chainA.GetContext() err := tc.clientState.VerifyPacketCommitment( - ctx, suite.store, suite.chainA.Codec, solomachine.GetHeight(), 0, 0, tc.prefix, tc.proof, testPortID, testChannelID, solomachine.Sequence, commitmentBytes, + ctx, suite.store, suite.chainA.Codec, sm.GetHeight(), 0, 0, tc.prefix, tc.proof, testPortID, testChannelID, sm.Sequence, commitmentBytes, ) if tc.expPass { @@ -620,17 +620,17 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketCommitment() { func (suite *SoloMachineTestSuite) TestVerifyPacketAcknowledgement() { ack := []byte("ACK") // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { - path := solomachine.GetPacketAcknowledgementPath(testPortID, testChannelID) + path := sm.GetPacketAcknowledgementPath(testPortID, testChannelID) - value, err := types.PacketAcknowledgementSignBytes(suite.chainA.Codec, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path, ack) + value, err := solomachine.PacketAcknowledgementSignBytes(suite.chainA.Codec, sm.Sequence, sm.Time, sm.Diversifier, path, ack) suite.Require().NoError(err) - sig := solomachine.GenerateSignature(value) - signatureDoc := &types.TimestampedSignatureData{ + sig := sm.GenerateSignature(value) + signatureDoc := &solomachine.TimestampedSignatureData{ SignatureData: sig, - Timestamp: solomachine.Time, + Timestamp: sm.Time, } proof, err := suite.chainA.Codec.Marshal(signatureDoc) @@ -638,35 +638,35 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketAcknowledgement() { testCases := []struct { name string - clientState *types.ClientState + clientState *solomachine.ClientState prefix exported.Prefix proof []byte expPass bool }{ { "successful verification", - solomachine.ClientState(), + sm.ClientState(), prefix, proof, true, }, { "ApplyPrefix failed", - solomachine.ClientState(), + sm.ClientState(), commitmenttypes.NewMerklePrefix([]byte{}), proof, false, }, { "proof is nil", - solomachine.ClientState(), + sm.ClientState(), prefix, nil, false, }, { "proof verification failed", - solomachine.ClientState(), + sm.ClientState(), prefix, suite.GetInvalidProof(), false, @@ -680,7 +680,7 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketAcknowledgement() { ctx := suite.chainA.GetContext() err := tc.clientState.VerifyPacketAcknowledgement( - ctx, suite.store, suite.chainA.Codec, solomachine.GetHeight(), 0, 0, tc.prefix, tc.proof, testPortID, testChannelID, solomachine.Sequence, ack, + ctx, suite.store, suite.chainA.Codec, sm.GetHeight(), 0, 0, tc.prefix, tc.proof, testPortID, testChannelID, sm.Sequence, ack, ) if tc.expPass { @@ -695,18 +695,18 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketAcknowledgement() { func (suite *SoloMachineTestSuite) TestVerifyPacketReceiptAbsence() { // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { // absence uses receipt path as well - path := solomachine.GetPacketReceiptPath(testPortID, testChannelID) + path := sm.GetPacketReceiptPath(testPortID, testChannelID) - value, err := types.PacketReceiptAbsenceSignBytes(suite.chainA.Codec, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path) + value, err := solomachine.PacketReceiptAbsenceSignBytes(suite.chainA.Codec, sm.Sequence, sm.Time, sm.Diversifier, path) suite.Require().NoError(err) - sig := solomachine.GenerateSignature(value) - signatureDoc := &types.TimestampedSignatureData{ + sig := sm.GenerateSignature(value) + signatureDoc := &solomachine.TimestampedSignatureData{ SignatureData: sig, - Timestamp: solomachine.Time, + Timestamp: sm.Time, } proof, err := suite.chainA.Codec.Marshal(signatureDoc) @@ -714,35 +714,35 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketReceiptAbsence() { testCases := []struct { name string - clientState *types.ClientState + clientState *solomachine.ClientState prefix exported.Prefix proof []byte expPass bool }{ { "successful verification", - solomachine.ClientState(), + sm.ClientState(), prefix, proof, true, }, { "ApplyPrefix failed", - solomachine.ClientState(), + sm.ClientState(), commitmenttypes.NewMerklePrefix([]byte{}), proof, false, }, { "proof is nil", - solomachine.ClientState(), + sm.ClientState(), prefix, nil, false, }, { "proof verification failed", - solomachine.ClientState(), + sm.ClientState(), prefix, suite.GetInvalidProof(), false, @@ -756,7 +756,7 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketReceiptAbsence() { ctx := suite.chainA.GetContext() err := tc.clientState.VerifyPacketReceiptAbsence( - ctx, suite.store, suite.chainA.Codec, solomachine.GetHeight(), 0, 0, tc.prefix, tc.proof, testPortID, testChannelID, solomachine.Sequence, + ctx, suite.store, suite.chainA.Codec, sm.GetHeight(), 0, 0, tc.prefix, tc.proof, testPortID, testChannelID, sm.Sequence, ) if tc.expPass { @@ -771,18 +771,18 @@ func (suite *SoloMachineTestSuite) TestVerifyPacketReceiptAbsence() { func (suite *SoloMachineTestSuite) TestVerifyNextSeqRecv() { // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { - nextSeqRecv := solomachine.Sequence + 1 - path := solomachine.GetNextSequenceRecvPath(testPortID, testChannelID) + nextSeqRecv := sm.Sequence + 1 + path := sm.GetNextSequenceRecvPath(testPortID, testChannelID) - value, err := types.NextSequenceRecvSignBytes(suite.chainA.Codec, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path, nextSeqRecv) + value, err := solomachine.NextSequenceRecvSignBytes(suite.chainA.Codec, sm.Sequence, sm.Time, sm.Diversifier, path, nextSeqRecv) suite.Require().NoError(err) - sig := solomachine.GenerateSignature(value) - signatureDoc := &types.TimestampedSignatureData{ + sig := sm.GenerateSignature(value) + signatureDoc := &solomachine.TimestampedSignatureData{ SignatureData: sig, - Timestamp: solomachine.Time, + Timestamp: sm.Time, } proof, err := suite.chainA.Codec.Marshal(signatureDoc) @@ -790,35 +790,35 @@ func (suite *SoloMachineTestSuite) TestVerifyNextSeqRecv() { testCases := []struct { name string - clientState *types.ClientState + clientState *solomachine.ClientState prefix exported.Prefix proof []byte expPass bool }{ { "successful verification", - solomachine.ClientState(), + sm.ClientState(), prefix, proof, true, }, { "ApplyPrefix failed", - solomachine.ClientState(), + sm.ClientState(), commitmenttypes.NewMerklePrefix([]byte{}), proof, false, }, { "proof is nil", - solomachine.ClientState(), + sm.ClientState(), prefix, nil, false, }, { "proof verification failed", - solomachine.ClientState(), + sm.ClientState(), prefix, suite.GetInvalidProof(), false, @@ -832,7 +832,7 @@ func (suite *SoloMachineTestSuite) TestVerifyNextSeqRecv() { ctx := suite.chainA.GetContext() err := tc.clientState.VerifyNextSequenceRecv( - ctx, suite.store, suite.chainA.Codec, solomachine.GetHeight(), 0, 0, tc.prefix, tc.proof, testPortID, testChannelID, nextSeqRecv, + ctx, suite.store, suite.chainA.Codec, sm.GetHeight(), 0, 0, tc.prefix, tc.proof, testPortID, testChannelID, nextSeqRecv, ) if tc.expPass { @@ -854,7 +854,7 @@ func (suite *SoloMachineTestSuite) TestGetTimestampAtHeight() { testCases := []struct { name string - clientState *types.ClientState + clientState *solomachine.ClientState height exported.Height expValue uint64 expPass bool diff --git a/modules/light-clients/06-solomachine/types/codec.go b/modules/light-clients/06-solomachine/codec.go similarity index 99% rename from modules/light-clients/06-solomachine/types/codec.go rename to modules/light-clients/06-solomachine/codec.go index 9ceccaef3cb..a857433ed56 100644 --- a/modules/light-clients/06-solomachine/types/codec.go +++ b/modules/light-clients/06-solomachine/codec.go @@ -1,4 +1,4 @@ -package types +package solomachine import ( "github.com/cosmos/cosmos-sdk/codec" diff --git a/modules/light-clients/06-solomachine/codec_test.go b/modules/light-clients/06-solomachine/codec_test.go new file mode 100644 index 00000000000..ff7d5084043 --- /dev/null +++ b/modules/light-clients/06-solomachine/codec_test.go @@ -0,0 +1,190 @@ +package solomachine_test + +import ( + clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" + connectiontypes "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types" + channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" + solomachine "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" + ibctesting "github.com/cosmos/ibc-go/v3/testing" +) + +func (suite SoloMachineTestSuite) TestUnmarshalDataByType() { + var ( + data []byte + err error + ) + + // test singlesig and multisig public keys + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + + cdc := suite.chainA.App.AppCodec() + cases := []struct { + name string + dataType solomachine.DataType + malleate func() + expPass bool + }{ + { + "empty data", solomachine.CLIENT, func() { + data = []byte{} + }, false, + }, + { + "unspecified", solomachine.UNSPECIFIED, func() { + path := sm.GetClientStatePath(counterpartyClientIdentifier) + data, err = solomachine.ClientStateDataBytes(cdc, path, sm.ClientState()) + suite.Require().NoError(err) + }, false, + }, + { + "client", solomachine.CLIENT, func() { + path := sm.GetClientStatePath(counterpartyClientIdentifier) + data, err = solomachine.ClientStateDataBytes(cdc, path, sm.ClientState()) + suite.Require().NoError(err) + }, true, + }, + { + "bad client (provides consensus state data)", solomachine.CLIENT, func() { + path := sm.GetConsensusStatePath(counterpartyClientIdentifier, clienttypes.NewHeight(0, 5)) + data, err = solomachine.ConsensusStateDataBytes(cdc, path, sm.ConsensusState()) + suite.Require().NoError(err) + }, false, + }, + { + "consensus", solomachine.CONSENSUS, func() { + path := sm.GetConsensusStatePath(counterpartyClientIdentifier, clienttypes.NewHeight(0, 5)) + data, err = solomachine.ConsensusStateDataBytes(cdc, path, sm.ConsensusState()) + suite.Require().NoError(err) + + }, true, + }, + { + "bad consensus (provides client state data)", solomachine.CONSENSUS, func() { + path := sm.GetClientStatePath(counterpartyClientIdentifier) + data, err = solomachine.ClientStateDataBytes(cdc, path, sm.ClientState()) + suite.Require().NoError(err) + }, false, + }, + { + "connection", solomachine.CONNECTION, func() { + counterparty := connectiontypes.NewCounterparty("clientB", testConnectionID, *prefix) + conn := connectiontypes.NewConnectionEnd(connectiontypes.OPEN, "clientA", counterparty, connectiontypes.ExportedVersionsToProto(connectiontypes.GetCompatibleVersions()), 0) + path := sm.GetConnectionStatePath("connectionID") + + data, err = solomachine.ConnectionStateDataBytes(cdc, path, conn) + suite.Require().NoError(err) + + }, true, + }, + { + "bad connection (uses channel data)", solomachine.CONNECTION, func() { + counterparty := channeltypes.NewCounterparty(testPortID, testChannelID) + ch := channeltypes.NewChannel(channeltypes.OPEN, channeltypes.ORDERED, counterparty, []string{testConnectionID}, "1.0.0") + path := sm.GetChannelStatePath("portID", "channelID") + + data, err = solomachine.ChannelStateDataBytes(cdc, path, ch) + suite.Require().NoError(err) + }, false, + }, + { + "channel", solomachine.CHANNEL, func() { + counterparty := channeltypes.NewCounterparty(testPortID, testChannelID) + ch := channeltypes.NewChannel(channeltypes.OPEN, channeltypes.ORDERED, counterparty, []string{testConnectionID}, "1.0.0") + path := sm.GetChannelStatePath("portID", "channelID") + + data, err = solomachine.ChannelStateDataBytes(cdc, path, ch) + suite.Require().NoError(err) + }, true, + }, + { + "bad channel (uses connection data)", solomachine.CHANNEL, func() { + counterparty := connectiontypes.NewCounterparty("clientB", testConnectionID, *prefix) + conn := connectiontypes.NewConnectionEnd(connectiontypes.OPEN, "clientA", counterparty, connectiontypes.ExportedVersionsToProto(connectiontypes.GetCompatibleVersions()), 0) + path := sm.GetConnectionStatePath("connectionID") + + data, err = solomachine.ConnectionStateDataBytes(cdc, path, conn) + suite.Require().NoError(err) + + }, false, + }, + { + "packet commitment", solomachine.PACKETCOMMITMENT, func() { + commitment := []byte("packet commitment") + path := sm.GetPacketCommitmentPath("portID", "channelID") + + data, err = solomachine.PacketCommitmentDataBytes(cdc, path, commitment) + suite.Require().NoError(err) + }, true, + }, + { + "bad packet commitment (uses next seq recv)", solomachine.PACKETCOMMITMENT, func() { + path := sm.GetNextSequenceRecvPath("portID", "channelID") + + data, err = solomachine.NextSequenceRecvDataBytes(cdc, path, 10) + suite.Require().NoError(err) + }, false, + }, + { + "packet acknowledgement", solomachine.PACKETACKNOWLEDGEMENT, func() { + commitment := []byte("packet acknowledgement") + path := sm.GetPacketAcknowledgementPath("portID", "channelID") + + data, err = solomachine.PacketAcknowledgementDataBytes(cdc, path, commitment) + suite.Require().NoError(err) + }, true, + }, + { + "bad packet acknowledgement (uses next sequence recv)", solomachine.PACKETACKNOWLEDGEMENT, func() { + path := sm.GetNextSequenceRecvPath("portID", "channelID") + + data, err = solomachine.NextSequenceRecvDataBytes(cdc, path, 10) + suite.Require().NoError(err) + }, false, + }, + { + "packet acknowledgement absence", solomachine.PACKETRECEIPTABSENCE, func() { + path := sm.GetPacketReceiptPath("portID", "channelID") + + data, err = solomachine.PacketReceiptAbsenceDataBytes(cdc, path) + suite.Require().NoError(err) + }, true, + }, + { + "next sequence recv", solomachine.NEXTSEQUENCERECV, func() { + path := sm.GetNextSequenceRecvPath("portID", "channelID") + + data, err = solomachine.NextSequenceRecvDataBytes(cdc, path, 10) + suite.Require().NoError(err) + }, true, + }, + { + "bad next sequence recv (uses packet commitment)", solomachine.NEXTSEQUENCERECV, func() { + commitment := []byte("packet commitment") + path := sm.GetPacketCommitmentPath("portID", "channelID") + + data, err = solomachine.PacketCommitmentDataBytes(cdc, path, commitment) + suite.Require().NoError(err) + }, false, + }, + } + + for _, tc := range cases { + tc := tc + + suite.Run(tc.name, func() { + tc.malleate() + + data, err := solomachine.UnmarshalDataByType(cdc, tc.dataType, data) + + if tc.expPass { + suite.Require().NoError(err) + suite.Require().NotNil(data) + } else { + suite.Require().Error(err) + suite.Require().Nil(data) + } + }) + } + } + +} diff --git a/modules/light-clients/06-solomachine/types/consensus_state.go b/modules/light-clients/06-solomachine/consensus_state.go similarity index 98% rename from modules/light-clients/06-solomachine/types/consensus_state.go rename to modules/light-clients/06-solomachine/consensus_state.go index 61b15b65882..35e11fa6064 100644 --- a/modules/light-clients/06-solomachine/types/consensus_state.go +++ b/modules/light-clients/06-solomachine/consensus_state.go @@ -1,4 +1,4 @@ -package types +package solomachine import ( "strings" diff --git a/modules/light-clients/06-solomachine/types/consensus_state_test.go b/modules/light-clients/06-solomachine/consensus_state_test.go similarity index 64% rename from modules/light-clients/06-solomachine/types/consensus_state_test.go rename to modules/light-clients/06-solomachine/consensus_state_test.go index 5b2b29cadcd..6b601a95cb6 100644 --- a/modules/light-clients/06-solomachine/types/consensus_state_test.go +++ b/modules/light-clients/06-solomachine/consensus_state_test.go @@ -1,8 +1,8 @@ -package types_test +package solomachine_test import ( "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" + solomachine "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) @@ -15,41 +15,41 @@ func (suite *SoloMachineTestSuite) TestConsensusState() { func (suite *SoloMachineTestSuite) TestConsensusStateValidateBasic() { // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { testCases := []struct { name string - consensusState *types.ConsensusState + consensusState *solomachine.ConsensusState expPass bool }{ { "valid consensus state", - solomachine.ConsensusState(), + sm.ConsensusState(), true, }, { "timestamp is zero", - &types.ConsensusState{ - PublicKey: solomachine.ConsensusState().PublicKey, + &solomachine.ConsensusState{ + PublicKey: sm.ConsensusState().PublicKey, Timestamp: 0, - Diversifier: solomachine.Diversifier, + Diversifier: sm.Diversifier, }, false, }, { "diversifier is blank", - &types.ConsensusState{ - PublicKey: solomachine.ConsensusState().PublicKey, - Timestamp: solomachine.Time, + &solomachine.ConsensusState{ + PublicKey: sm.ConsensusState().PublicKey, + Timestamp: sm.Time, Diversifier: " ", }, false, }, { "pubkey is nil", - &types.ConsensusState{ - Timestamp: solomachine.Time, - Diversifier: solomachine.Diversifier, + &solomachine.ConsensusState{ + Timestamp: sm.Time, + Diversifier: sm.Diversifier, PublicKey: nil, }, false, diff --git a/modules/light-clients/06-solomachine/types/errors.go b/modules/light-clients/06-solomachine/errors.go similarity index 97% rename from modules/light-clients/06-solomachine/types/errors.go rename to modules/light-clients/06-solomachine/errors.go index 3e27f60732a..73ca5999dbc 100644 --- a/modules/light-clients/06-solomachine/types/errors.go +++ b/modules/light-clients/06-solomachine/errors.go @@ -1,4 +1,4 @@ -package types +package solomachine import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/modules/light-clients/06-solomachine/types/header.go b/modules/light-clients/06-solomachine/header.go similarity index 98% rename from modules/light-clients/06-solomachine/types/header.go rename to modules/light-clients/06-solomachine/header.go index a6639a0f0c9..f2a63ef4ddb 100644 --- a/modules/light-clients/06-solomachine/types/header.go +++ b/modules/light-clients/06-solomachine/header.go @@ -1,4 +1,4 @@ -package types +package solomachine import ( "strings" diff --git a/modules/light-clients/06-solomachine/types/header_test.go b/modules/light-clients/06-solomachine/header_test.go similarity index 83% rename from modules/light-clients/06-solomachine/types/header_test.go rename to modules/light-clients/06-solomachine/header_test.go index 48ce858c76a..5b02b41c555 100644 --- a/modules/light-clients/06-solomachine/types/header_test.go +++ b/modules/light-clients/06-solomachine/header_test.go @@ -1,20 +1,20 @@ -package types_test +package solomachine_test import ( "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" + solomachine "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { - header := solomachine.CreateHeader() + header := sm.CreateHeader() cases := []struct { name string - header *types.Header + header *solomachine.Header expPass bool }{ { @@ -24,7 +24,7 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { }, { "sequence is zero", - &types.Header{ + &solomachine.Header{ Sequence: 0, Timestamp: header.Timestamp, Signature: header.Signature, @@ -35,7 +35,7 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { }, { "timestamp is zero", - &types.Header{ + &solomachine.Header{ Sequence: header.Sequence, Timestamp: 0, Signature: header.Signature, @@ -46,7 +46,7 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { }, { "signature is empty", - &types.Header{ + &solomachine.Header{ Sequence: header.Sequence, Timestamp: header.Timestamp, Signature: []byte{}, @@ -57,7 +57,7 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { }, { "diversifier contains only spaces", - &types.Header{ + &solomachine.Header{ Sequence: header.Sequence, Timestamp: header.Timestamp, Signature: header.Signature, @@ -68,7 +68,7 @@ func (suite *SoloMachineTestSuite) TestHeaderValidateBasic() { }, { "public key is nil", - &types.Header{ + &solomachine.Header{ Sequence: header.Sequence, Timestamp: header.Timestamp, Signature: header.Signature, diff --git a/modules/light-clients/06-solomachine/types/misbehaviour.go b/modules/light-clients/06-solomachine/misbehaviour.go similarity index 99% rename from modules/light-clients/06-solomachine/types/misbehaviour.go rename to modules/light-clients/06-solomachine/misbehaviour.go index 0b4c2f3bcd0..145841e4b0e 100644 --- a/modules/light-clients/06-solomachine/types/misbehaviour.go +++ b/modules/light-clients/06-solomachine/misbehaviour.go @@ -1,4 +1,4 @@ -package types +package solomachine import ( "bytes" diff --git a/modules/light-clients/06-solomachine/types/misbehaviour_handle.go b/modules/light-clients/06-solomachine/misbehaviour_handle.go similarity index 98% rename from modules/light-clients/06-solomachine/types/misbehaviour_handle.go rename to modules/light-clients/06-solomachine/misbehaviour_handle.go index becf8a654a5..c5f53239fd2 100644 --- a/modules/light-clients/06-solomachine/types/misbehaviour_handle.go +++ b/modules/light-clients/06-solomachine/misbehaviour_handle.go @@ -1,4 +1,4 @@ -package types +package solomachine import ( "github.com/cosmos/cosmos-sdk/codec" diff --git a/modules/light-clients/06-solomachine/types/misbehaviour_test.go b/modules/light-clients/06-solomachine/misbehaviour_test.go similarity index 65% rename from modules/light-clients/06-solomachine/types/misbehaviour_test.go rename to modules/light-clients/06-solomachine/misbehaviour_test.go index d7c41996e19..0bb533a7660 100644 --- a/modules/light-clients/06-solomachine/types/misbehaviour_test.go +++ b/modules/light-clients/06-solomachine/misbehaviour_test.go @@ -1,8 +1,8 @@ -package types_test +package solomachine_test import ( "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" + solomachine "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) @@ -14,95 +14,95 @@ func (suite *SoloMachineTestSuite) TestMisbehaviour() { func (suite *SoloMachineTestSuite) TestMisbehaviourValidateBasic() { // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { testCases := []struct { name string - malleateMisbehaviour func(misbehaviour *types.Misbehaviour) + malleateMisbehaviour func(misbehaviour *solomachine.Misbehaviour) expPass bool }{ { "valid misbehaviour", - func(*types.Misbehaviour) {}, + func(*solomachine.Misbehaviour) {}, true, }, { "invalid client ID", - func(misbehaviour *types.Misbehaviour) { + func(misbehaviour *solomachine.Misbehaviour) { misbehaviour.ClientId = "(badclientid)" }, false, }, { "sequence is zero", - func(misbehaviour *types.Misbehaviour) { + func(misbehaviour *solomachine.Misbehaviour) { misbehaviour.Sequence = 0 }, false, }, { "signature one sig is empty", - func(misbehaviour *types.Misbehaviour) { + func(misbehaviour *solomachine.Misbehaviour) { misbehaviour.SignatureOne.Signature = []byte{} }, false, }, { "signature two sig is empty", - func(misbehaviour *types.Misbehaviour) { + func(misbehaviour *solomachine.Misbehaviour) { misbehaviour.SignatureTwo.Signature = []byte{} }, false, }, { "signature one data is empty", - func(misbehaviour *types.Misbehaviour) { + func(misbehaviour *solomachine.Misbehaviour) { misbehaviour.SignatureOne.Data = nil }, false, }, { "signature two data is empty", - func(misbehaviour *types.Misbehaviour) { + func(misbehaviour *solomachine.Misbehaviour) { misbehaviour.SignatureTwo.Data = []byte{} }, false, }, { "signatures are identical", - func(misbehaviour *types.Misbehaviour) { + func(misbehaviour *solomachine.Misbehaviour) { misbehaviour.SignatureTwo.Signature = misbehaviour.SignatureOne.Signature }, false, }, { "data signed is identical", - func(misbehaviour *types.Misbehaviour) { + func(misbehaviour *solomachine.Misbehaviour) { misbehaviour.SignatureTwo.Data = misbehaviour.SignatureOne.Data }, false, }, { "data type for SignatureOne is unspecified", - func(misbehaviour *types.Misbehaviour) { - misbehaviour.SignatureOne.DataType = types.UNSPECIFIED + func(misbehaviour *solomachine.Misbehaviour) { + misbehaviour.SignatureOne.DataType = solomachine.UNSPECIFIED }, false, }, { "data type for SignatureTwo is unspecified", - func(misbehaviour *types.Misbehaviour) { - misbehaviour.SignatureTwo.DataType = types.UNSPECIFIED + func(misbehaviour *solomachine.Misbehaviour) { + misbehaviour.SignatureTwo.DataType = solomachine.UNSPECIFIED }, false, }, { "timestamp for SignatureOne is zero", - func(misbehaviour *types.Misbehaviour) { + func(misbehaviour *solomachine.Misbehaviour) { misbehaviour.SignatureOne.Timestamp = 0 }, false, }, { "timestamp for SignatureTwo is zero", - func(misbehaviour *types.Misbehaviour) { + func(misbehaviour *solomachine.Misbehaviour) { misbehaviour.SignatureTwo.Timestamp = 0 }, false, }, @@ -113,7 +113,7 @@ func (suite *SoloMachineTestSuite) TestMisbehaviourValidateBasic() { suite.Run(tc.name, func() { - misbehaviour := solomachine.CreateMisbehaviour() + misbehaviour := sm.CreateMisbehaviour() tc.malleateMisbehaviour(misbehaviour) err := misbehaviour.ValidateBasic() diff --git a/modules/light-clients/06-solomachine/module.go b/modules/light-clients/06-solomachine/module.go index d607282725a..d66b482541c 100644 --- a/modules/light-clients/06-solomachine/module.go +++ b/modules/light-clients/06-solomachine/module.go @@ -1,10 +1,6 @@ package solomachine -import ( - "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" -) - // Name returns the solo machine client name. func Name() string { - return types.SubModuleName + return SubModuleName } diff --git a/modules/light-clients/06-solomachine/types/proof.go b/modules/light-clients/06-solomachine/proof.go similarity index 99% rename from modules/light-clients/06-solomachine/types/proof.go rename to modules/light-clients/06-solomachine/proof.go index f884a26d745..cdbd8f19983 100644 --- a/modules/light-clients/06-solomachine/types/proof.go +++ b/modules/light-clients/06-solomachine/proof.go @@ -1,4 +1,4 @@ -package types +package solomachine import ( "github.com/cosmos/cosmos-sdk/codec" diff --git a/modules/light-clients/06-solomachine/types/proof_test.go b/modules/light-clients/06-solomachine/proof_test.go similarity index 57% rename from modules/light-clients/06-solomachine/types/proof_test.go rename to modules/light-clients/06-solomachine/proof_test.go index 65e88aa3bde..dd7bb52ec1e 100644 --- a/modules/light-clients/06-solomachine/types/proof_test.go +++ b/modules/light-clients/06-solomachine/proof_test.go @@ -1,11 +1,10 @@ -package types_test +package solomachine_test import ( cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/types/tx/signing" - "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" + solomachine "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) @@ -14,11 +13,11 @@ func (suite *SoloMachineTestSuite) TestVerifySignature() { signBytes := []byte("sign bytes") singleSignature := suite.solomachine.GenerateSignature(signBytes) - singleSigData, err := solomachinetypes.UnmarshalSignatureData(cdc, singleSignature) + singleSigData, err := solomachine.UnmarshalSignatureData(cdc, singleSignature) suite.Require().NoError(err) multiSignature := suite.solomachineMulti.GenerateSignature(signBytes) - multiSigData, err := solomachinetypes.UnmarshalSignatureData(cdc, multiSignature) + multiSigData, err := solomachine.UnmarshalSignatureData(cdc, multiSignature) suite.Require().NoError(err) testCases := []struct { @@ -57,7 +56,7 @@ func (suite *SoloMachineTestSuite) TestVerifySignature() { tc := tc suite.Run(tc.name, func() { - err := solomachinetypes.VerifySignature(tc.publicKey, signBytes, tc.sigData) + err := solomachine.VerifySignature(tc.publicKey, signBytes, tc.sigData) if tc.expPass { suite.Require().NoError(err) @@ -71,15 +70,15 @@ func (suite *SoloMachineTestSuite) TestVerifySignature() { func (suite *SoloMachineTestSuite) TestClientStateSignBytes() { cdc := suite.chainA.App.AppCodec() - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { // success - path := solomachine.GetClientStatePath(counterpartyClientIdentifier) - bz, err := types.ClientStateSignBytes(cdc, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path, solomachine.ClientState()) + path := sm.GetClientStatePath(counterpartyClientIdentifier) + bz, err := solomachine.ClientStateSignBytes(cdc, sm.Sequence, sm.Time, sm.Diversifier, path, sm.ClientState()) suite.Require().NoError(err) suite.Require().NotNil(bz) // nil client state - bz, err = types.ClientStateSignBytes(cdc, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path, nil) + bz, err = solomachine.ClientStateSignBytes(cdc, sm.Sequence, sm.Time, sm.Diversifier, path, nil) suite.Require().Error(err) suite.Require().Nil(bz) } @@ -88,15 +87,15 @@ func (suite *SoloMachineTestSuite) TestClientStateSignBytes() { func (suite *SoloMachineTestSuite) TestConsensusStateSignBytes() { cdc := suite.chainA.App.AppCodec() - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { // success - path := solomachine.GetConsensusStatePath(counterpartyClientIdentifier, consensusHeight) - bz, err := types.ConsensusStateSignBytes(cdc, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path, solomachine.ConsensusState()) + path := sm.GetConsensusStatePath(counterpartyClientIdentifier, consensusHeight) + bz, err := solomachine.ConsensusStateSignBytes(cdc, sm.Sequence, sm.Time, sm.Diversifier, path, sm.ConsensusState()) suite.Require().NoError(err) suite.Require().NotNil(bz) // nil consensus state - bz, err = types.ConsensusStateSignBytes(cdc, solomachine.Sequence, solomachine.Time, solomachine.Diversifier, path, nil) + bz, err = solomachine.ConsensusStateSignBytes(cdc, sm.Sequence, sm.Time, sm.Diversifier, path, nil) suite.Require().Error(err) suite.Require().Nil(bz) } diff --git a/modules/light-clients/06-solomachine/types/proposal_handle.go b/modules/light-clients/06-solomachine/proposal_handle.go similarity index 99% rename from modules/light-clients/06-solomachine/types/proposal_handle.go rename to modules/light-clients/06-solomachine/proposal_handle.go index 456129537f4..4a32e2af2e1 100644 --- a/modules/light-clients/06-solomachine/types/proposal_handle.go +++ b/modules/light-clients/06-solomachine/proposal_handle.go @@ -1,4 +1,4 @@ -package types +package solomachine import ( "reflect" diff --git a/modules/light-clients/06-solomachine/types/proposal_handle_test.go b/modules/light-clients/06-solomachine/proposal_handle_test.go similarity index 71% rename from modules/light-clients/06-solomachine/types/proposal_handle_test.go rename to modules/light-clients/06-solomachine/proposal_handle_test.go index fbb814c0791..26f04b93326 100644 --- a/modules/light-clients/06-solomachine/types/proposal_handle_test.go +++ b/modules/light-clients/06-solomachine/proposal_handle_test.go @@ -1,22 +1,22 @@ -package types_test +package solomachine_test import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + solomachine "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) func (suite *SoloMachineTestSuite) TestCheckSubstituteAndUpdateState() { var ( - subjectClientState *types.ClientState + subjectClientState *solomachine.ClientState substituteClientState exported.ClientState ) // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { testCases := []struct { name string @@ -46,12 +46,12 @@ func (suite *SoloMachineTestSuite) TestCheckSubstituteAndUpdateState() { { "substitute public key is nil", func() { - substituteClientState.(*types.ClientState).ConsensusState.PublicKey = nil + substituteClientState.(*solomachine.ClientState).ConsensusState.PublicKey = nil }, false, }, { "subject and substitute use the same public key", func() { - substituteClientState.(*types.ClientState).ConsensusState.PublicKey = subjectClientState.ConsensusState.PublicKey + substituteClientState.(*solomachine.ClientState).ConsensusState.PublicKey = subjectClientState.ConsensusState.PublicKey }, false, }, } @@ -62,14 +62,14 @@ func (suite *SoloMachineTestSuite) TestCheckSubstituteAndUpdateState() { suite.Run(tc.name, func() { suite.SetupTest() - subjectClientState = solomachine.ClientState() + subjectClientState = sm.ClientState() subjectClientState.AllowUpdateAfterProposal = true substitute := ibctesting.NewSolomachine(suite.T(), suite.chainA.Codec, "substitute", "testing", 5) substituteClientState = substitute.ClientState() tc.malleate() - subjectClientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), solomachine.ClientID) + subjectClientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), sm.ClientID) substituteClientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), substitute.ClientID) updatedClient, err := subjectClientState.CheckSubstituteAndUpdateState(suite.chainA.GetContext(), suite.chainA.App.AppCodec(), subjectClientStore, substituteClientStore, substituteClientState) @@ -77,9 +77,9 @@ func (suite *SoloMachineTestSuite) TestCheckSubstituteAndUpdateState() { if tc.expPass { suite.Require().NoError(err) - suite.Require().Equal(substituteClientState.(*types.ClientState).ConsensusState, updatedClient.(*types.ClientState).ConsensusState) - suite.Require().Equal(substituteClientState.(*types.ClientState).Sequence, updatedClient.(*types.ClientState).Sequence) - suite.Require().Equal(false, updatedClient.(*types.ClientState).IsFrozen) + suite.Require().Equal(substituteClientState.(*solomachine.ClientState).ConsensusState, updatedClient.(*solomachine.ClientState).ConsensusState) + suite.Require().Equal(substituteClientState.(*solomachine.ClientState).Sequence, updatedClient.(*solomachine.ClientState).Sequence) + suite.Require().Equal(false, updatedClient.(*solomachine.ClientState).IsFrozen) // ensure updated client state is set in store bz := subjectClientStore.Get(host.ClientStateKey()) diff --git a/modules/light-clients/06-solomachine/types/solomachine.go b/modules/light-clients/06-solomachine/solomachine.go similarity index 98% rename from modules/light-clients/06-solomachine/types/solomachine.go rename to modules/light-clients/06-solomachine/solomachine.go index 90eff77d200..e3d58781ea8 100644 --- a/modules/light-clients/06-solomachine/types/solomachine.go +++ b/modules/light-clients/06-solomachine/solomachine.go @@ -1,4 +1,4 @@ -package types +package solomachine import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/modules/light-clients/06-solomachine/types/solomachine.pb.go b/modules/light-clients/06-solomachine/solomachine.pb.go similarity index 98% rename from modules/light-clients/06-solomachine/types/solomachine.pb.go rename to modules/light-clients/06-solomachine/solomachine.pb.go index 6eafde55d0c..845195afbdd 100644 --- a/modules/light-clients/06-solomachine/types/solomachine.pb.go +++ b/modules/light-clients/06-solomachine/solomachine.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: ibc/lightclients/solomachine/v2/solomachine.proto -package types +package solomachine import ( fmt "fmt" @@ -824,11 +824,11 @@ func init() { } var fileDescriptor_141333b361aae010 = []byte{ - // 1373 bytes of a gzipped FileDescriptorProto + // 1372 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x57, 0x5f, 0x6f, 0xdb, 0x54, 0x14, 0xaf, 0xb3, 0xac, 0x6b, 0x4e, 0xba, 0x36, 0x78, 0xd9, 0x96, 0x7a, 0x53, 0x62, 0x8c, 0x18, - 0x05, 0xb1, 0x84, 0x76, 0x62, 0x42, 0x13, 0x02, 0x1c, 0xc7, 0x63, 0xd9, 0x5a, 0x37, 0x38, 0x2e, - 0xb0, 0x09, 0xc9, 0x38, 0xce, 0x6d, 0x62, 0x2d, 0xf1, 0xcd, 0x62, 0x27, 0x59, 0x90, 0x90, 0x10, + 0x05, 0xb1, 0x84, 0x76, 0x62, 0x42, 0x03, 0x01, 0x8e, 0xe3, 0xb1, 0x6c, 0xad, 0x1b, 0x1c, 0x17, + 0xd8, 0x84, 0x64, 0x39, 0xce, 0x6d, 0x62, 0x2d, 0xf1, 0xcd, 0x62, 0x27, 0x59, 0x90, 0x90, 0x10, 0x4f, 0x23, 0xe2, 0x81, 0x2f, 0x10, 0x09, 0x81, 0xf8, 0x1c, 0xbc, 0x21, 0x78, 0xdb, 0x23, 0x4f, 0x01, 0x6d, 0xdf, 0x20, 0x9f, 0x00, 0xd9, 0xf7, 0x26, 0xb6, 0xd3, 0x35, 0x15, 0xff, 0xde, 0xee, 0x3d, 0xbf, 0x73, 0x7e, 0xe7, 0xcf, 0x3d, 0x3e, 0xf7, 0x1a, 0x76, 0xac, 0x9a, 0x59, 0x68, 0x59, @@ -864,11 +864,11 @@ var fileDescriptor_141333b361aae010 = []byte{ 0xe8, 0xd8, 0x9e, 0x35, 0xfb, 0xce, 0xa9, 0xcd, 0x5e, 0x9d, 0x59, 0x89, 0x76, 0xbd, 0x64, 0xb8, 0x46, 0x31, 0x33, 0x9d, 0xe4, 0xd2, 0x24, 0x8e, 0x08, 0xa3, 0xa0, 0xae, 0xcf, 0xf7, 0x07, 0xf6, 0x82, 0x47, 0x77, 0x80, 0x69, 0xd1, 0xff, 0x2b, 0x8f, 0xee, 0x00, 0x87, 0x3d, 0x6a, 0x03, 0x4c, - 0x6b, 0xf9, 0x0b, 0x03, 0xa9, 0x45, 0x8a, 0x68, 0x83, 0x30, 0x8b, 0x0d, 0xf2, 0x19, 0x24, 0xea, + 0x6b, 0xf9, 0x0b, 0x03, 0xa9, 0x45, 0x8a, 0x68, 0x83, 0x30, 0x8b, 0x0d, 0xf2, 0x39, 0x24, 0xea, 0x86, 0x6b, 0xe8, 0xee, 0xb0, 0x43, 0x2a, 0xb7, 0xb1, 0xfb, 0xfa, 0xa9, 0x61, 0x7a, 0xbc, 0xda, 0xb0, 0x83, 0xc2, 0x93, 0x66, 0xce, 0x22, 0xa8, 0x6b, 0x75, 0x8a, 0xb3, 0x2c, 0xc4, 0xbd, 0x35, 0xed, 0x4b, 0x7f, 0x1d, 0x6d, 0xe7, 0xf8, 0x8b, 0xbf, 0x8c, 0xaf, 0x18, 0xc8, 0x68, 0x33, 0x19, - 0xaa, 0xcf, 0x73, 0xf2, 0x13, 0xfa, 0x00, 0x36, 0x82, 0x5a, 0xf8, 0xf4, 0x7e, 0x56, 0xe1, 0xee, + 0xaa, 0xcf, 0x73, 0xf2, 0x13, 0xfa, 0x10, 0x36, 0x82, 0x5a, 0xf8, 0xf4, 0x7e, 0x56, 0xe1, 0xee, 0x8d, 0xe2, 0x82, 0x1a, 0x1c, 0x47, 0xe9, 0x58, 0x08, 0xb1, 0x17, 0x87, 0xf0, 0x07, 0x03, 0x09, 0xcf, 0x6f, 0x71, 0xe8, 0x22, 0xe7, 0x5f, 0x7c, 0x9f, 0x0b, 0xa3, 0xe2, 0xcc, 0xf1, 0x51, 0x11, 0x39, 0x82, 0xf8, 0xff, 0x75, 0x04, 0x67, 0x83, 0x23, 0xa0, 0x19, 0xfe, 0xc4, 0x00, 0x90, 0xf1, @@ -886,7 +886,7 @@ var fileDescriptor_141333b361aae010 = []byte{ 0xdf, 0xd9, 0xba, 0x1a, 0x92, 0x08, 0xf7, 0x61, 0x8b, 0x70, 0x89, 0xe6, 0x43, 0x1b, 0x0f, 0x5a, 0xa8, 0xde, 0x40, 0x4b, 0x09, 0xb7, 0x61, 0xd3, 0x88, 0xaa, 0x52, 0xd6, 0x45, 0xb1, 0x90, 0x87, 0x0c, 0xa1, 0x56, 0x91, 0x89, 0xac, 0x8e, 0x2b, 0xd6, 0x1c, 0x6f, 0x0e, 0x9c, 0xc4, 0x2c, 0x34, - 0x21, 0xad, 0xa0, 0xc7, 0x6e, 0x95, 0xce, 0x0b, 0x15, 0x99, 0xfd, 0x13, 0xa3, 0x78, 0x17, 0xce, + 0x21, 0xad, 0xa0, 0xc7, 0x6e, 0x95, 0xce, 0x0b, 0x15, 0x99, 0xfd, 0x13, 0xa3, 0x78, 0x0f, 0xce, 0xdb, 0xe8, 0xb1, 0xab, 0x3b, 0xe8, 0x91, 0xde, 0x45, 0x66, 0x9f, 0xcc, 0x93, 0xf0, 0x35, 0x10, 0x81, 0x05, 0x35, 0x69, 0x13, 0x6a, 0x8f, 0xf5, 0x8d, 0x6f, 0xe3, 0xb0, 0x36, 0x1b, 0x0c, 0xec, 0x3b, 0xf0, 0x4a, 0x49, 0xd4, 0x44, 0x5d, 0xbb, 0x5f, 0x91, 0xf5, 0x43, 0xa5, 0xac, 0x94, 0xb5, @@ -898,19 +898,19 @@ var fileDescriptor_141333b361aae010 = []byte{ 0xaa, 0x7e, 0x86, 0xdb, 0x18, 0x8d, 0x79, 0x08, 0xe4, 0xec, 0x36, 0x5c, 0x0e, 0xe9, 0xdf, 0x11, 0x15, 0x45, 0xde, 0xa3, 0xca, 0x71, 0x2e, 0x39, 0x1a, 0xf3, 0xe7, 0xa8, 0x90, 0x7d, 0x1b, 0xae, 0x04, 0x9a, 0x15, 0x51, 0xba, 0x27, 0x6b, 0xba, 0x74, 0xb0, 0xbf, 0x5f, 0xd6, 0xf6, 0x65, 0x45, - 0x4b, 0x9d, 0xe5, 0xd2, 0xa3, 0x31, 0x9f, 0x22, 0x40, 0x20, 0x67, 0xdf, 0x07, 0xfe, 0x98, 0x99, - 0x28, 0xdd, 0x53, 0x0e, 0x3e, 0xd9, 0x93, 0x4b, 0x1f, 0xca, 0xbe, 0xed, 0x2a, 0xb7, 0x35, 0x1a, - 0xf3, 0x17, 0x09, 0xba, 0x00, 0xb2, 0xef, 0xbd, 0x80, 0x40, 0x95, 0x25, 0xb9, 0x5c, 0xd1, 0x74, + 0x4b, 0x9d, 0xe5, 0xd2, 0xa3, 0x31, 0x9f, 0x22, 0x40, 0x20, 0x67, 0x3f, 0x00, 0xfe, 0x98, 0x99, + 0x28, 0xdd, 0x53, 0x0e, 0x3e, 0xdd, 0x93, 0x4b, 0x1f, 0xc9, 0xbe, 0xed, 0x2a, 0xb7, 0x35, 0x1a, + 0xf3, 0x17, 0x09, 0xba, 0x00, 0xb2, 0xef, 0xbf, 0x80, 0x40, 0x95, 0x25, 0xb9, 0x5c, 0xd1, 0x74, 0xb1, 0x58, 0x95, 0x15, 0x49, 0x4e, 0x9d, 0xe3, 0x32, 0xa3, 0x31, 0x9f, 0x26, 0x28, 0x05, 0x29, - 0xc6, 0xde, 0x84, 0xab, 0x81, 0xbd, 0x22, 0x7f, 0xaa, 0xe9, 0x55, 0xf9, 0xa3, 0x43, 0x0f, 0xf2, - 0x68, 0x3e, 0x4e, 0xad, 0x91, 0xc0, 0x3d, 0x64, 0x06, 0x78, 0x72, 0x96, 0x87, 0x54, 0x60, 0x77, + 0xc6, 0xde, 0x84, 0xab, 0x81, 0xbd, 0x22, 0x7f, 0xa6, 0xe9, 0x55, 0xf9, 0xe3, 0x43, 0x0f, 0xf2, + 0x68, 0x3e, 0x49, 0xad, 0x91, 0xc0, 0x3d, 0x64, 0x06, 0x78, 0x72, 0x96, 0x87, 0x54, 0x60, 0x77, 0x47, 0x16, 0x4b, 0xb2, 0x9a, 0x4a, 0x90, 0x93, 0x21, 0x3b, 0x2e, 0xfe, 0xe4, 0xc7, 0xec, 0x4a, - 0xf1, 0xf3, 0x5f, 0x9f, 0x65, 0x99, 0xa7, 0xcf, 0xb2, 0xcc, 0x9f, 0xcf, 0xb2, 0xcc, 0x77, 0xcf, - 0xb3, 0x2b, 0x4f, 0x9f, 0x67, 0x57, 0x7e, 0x7f, 0x9e, 0x5d, 0x79, 0x70, 0xbb, 0x61, 0xb9, 0xcd, - 0x5e, 0x2d, 0x6f, 0xe2, 0x76, 0xc1, 0xc4, 0x4e, 0x1b, 0x3b, 0x05, 0xab, 0x66, 0x5e, 0x6f, 0xe0, - 0x42, 0xff, 0x46, 0xa1, 0x8d, 0xeb, 0xbd, 0x16, 0x72, 0xc8, 0x1f, 0xd5, 0xf5, 0xd9, 0x2f, 0xd5, - 0x5b, 0x37, 0xaf, 0x87, 0xff, 0xaa, 0xbc, 0x6b, 0xc6, 0xa9, 0xad, 0xfa, 0xf3, 0xec, 0xc6, 0x5f, - 0x01, 0x00, 0x00, 0xff, 0xff, 0xe7, 0x08, 0x62, 0xbe, 0x82, 0x0d, 0x00, 0x00, + 0xf1, 0xe8, 0xd7, 0x67, 0x59, 0xe6, 0xe9, 0xb3, 0x2c, 0xf3, 0xe7, 0xb3, 0x2c, 0xf3, 0xdd, 0xf3, + 0xec, 0xca, 0xd3, 0xe7, 0xd9, 0x95, 0xdf, 0x9f, 0x67, 0x57, 0x1e, 0xec, 0x35, 0x2c, 0xb7, 0xd9, + 0xab, 0xe5, 0x4d, 0xdc, 0x2e, 0x98, 0xd8, 0x69, 0x63, 0xa7, 0x60, 0xd5, 0xcc, 0xeb, 0x0d, 0x5c, + 0xe8, 0xdf, 0x28, 0xb4, 0x71, 0xbd, 0xd7, 0x42, 0x0e, 0xf9, 0xa3, 0xba, 0x3e, 0xfb, 0xa5, 0x7a, + 0xeb, 0xe6, 0xf5, 0xd0, 0x15, 0xf4, 0x6e, 0x68, 0x5d, 0x5b, 0xf5, 0xa7, 0xda, 0x8d, 0xbf, 0x02, + 0x00, 0x00, 0xff, 0xff, 0xcc, 0xc1, 0x35, 0x7d, 0x88, 0x0d, 0x00, 0x00, } func (m *ClientState) Marshal() (dAtA []byte, err error) { diff --git a/modules/light-clients/06-solomachine/types/solomachine_test.go b/modules/light-clients/06-solomachine/solomachine_test.go similarity index 85% rename from modules/light-clients/06-solomachine/types/solomachine_test.go rename to modules/light-clients/06-solomachine/solomachine_test.go index 56ebadee3d1..c913d776fc2 100644 --- a/modules/light-clients/06-solomachine/types/solomachine_test.go +++ b/modules/light-clients/06-solomachine/solomachine_test.go @@ -1,4 +1,4 @@ -package types_test +package solomachine_test import ( "testing" @@ -6,7 +6,6 @@ import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/secp256k1" - cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" "github.com/cosmos/cosmos-sdk/testutil/testdata" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/stretchr/testify/require" @@ -14,7 +13,7 @@ import ( host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" + solomachine "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) @@ -58,7 +57,7 @@ func (suite *SoloMachineTestSuite) GetSequenceFromStore() uint64 { } func (suite *SoloMachineTestSuite) GetInvalidProof() []byte { - invalidProof, err := suite.chainA.Codec.Marshal(&types.TimestampedSignatureData{Timestamp: suite.solomachine.Time}) + invalidProof, err := suite.chainA.Codec.Marshal(&solomachine.TimestampedSignatureData{Timestamp: suite.solomachine.Time}) suite.Require().NoError(err) return invalidProof @@ -68,17 +67,17 @@ func TestUnpackInterfaces_Header(t *testing.T) { registry := testdata.NewTestInterfaceRegistry() cryptocodec.RegisterInterfaces(registry) - pk := secp256k1.GenPrivKey().PubKey().(cryptotypes.PubKey) + pk := secp256k1.GenPrivKey().PubKey() any, err := codectypes.NewAnyWithValue(pk) require.NoError(t, err) - header := types.Header{ + header := solomachine.Header{ NewPublicKey: any, } bz, err := header.Marshal() require.NoError(t, err) - var header2 types.Header + var header2 solomachine.Header err = header2.Unmarshal(bz) require.NoError(t, err) @@ -92,17 +91,17 @@ func TestUnpackInterfaces_HeaderData(t *testing.T) { registry := testdata.NewTestInterfaceRegistry() cryptocodec.RegisterInterfaces(registry) - pk := secp256k1.GenPrivKey().PubKey().(cryptotypes.PubKey) + pk := secp256k1.GenPrivKey().PubKey() any, err := codectypes.NewAnyWithValue(pk) require.NoError(t, err) - hd := types.HeaderData{ + hd := solomachine.HeaderData{ NewPubKey: any, } bz, err := hd.Marshal() require.NoError(t, err) - var hd2 types.HeaderData + var hd2 solomachine.HeaderData err = hd2.Unmarshal(bz) require.NoError(t, err) diff --git a/modules/light-clients/06-solomachine/spec/01_concepts.md b/modules/light-clients/06-solomachine/spec/01_concepts.md index 75d31bf5340..602c9947f71 100644 --- a/modules/light-clients/06-solomachine/spec/01_concepts.md +++ b/modules/light-clients/06-solomachine/spec/01_concepts.md @@ -56,7 +56,7 @@ data := &ClientStateData{ dataBz, err := cdc.Marshal(data) ``` -The helper functions `...DataBytes()` in [proof.go](../types/proof.go) handle this +The helper functions `...DataBytes()` in [proof.go](../proof.go) handle this functionality. 2. Construct the `SignBytes` and marshal it. @@ -75,7 +75,7 @@ signBytes := &SignBytes{ signBz, err := cdc.Marshal(signBytes) ``` -The helper functions `...SignBytes()` in [proof.go](../types/proof.go) handle this functionality. +The helper functions `...SignBytes()` in [proof.go](../proof.go) handle this functionality. The `DataType` field is used to disambiguate what type of data was signed to prevent potential proto encoding overlap. @@ -100,7 +100,7 @@ as the proof parameter to the verification functions. For example: ```go -timestampedSignatureData := &types.TimestampedSignatureData{ +timestampedSignatureData := &solomachine.TimestampedSignatureData{ SignatureData: sigData, Timestamp: solomachine.Time, } diff --git a/modules/light-clients/06-solomachine/types/codec_test.go b/modules/light-clients/06-solomachine/types/codec_test.go deleted file mode 100644 index 1a0e3e0086f..00000000000 --- a/modules/light-clients/06-solomachine/types/codec_test.go +++ /dev/null @@ -1,190 +0,0 @@ -package types_test - -import ( - clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - connectiontypes "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types" - channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" - "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - ibctesting "github.com/cosmos/ibc-go/v3/testing" -) - -func (suite SoloMachineTestSuite) TestUnmarshalDataByType() { - var ( - data []byte - err error - ) - - // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { - - cdc := suite.chainA.App.AppCodec() - cases := []struct { - name string - dataType types.DataType - malleate func() - expPass bool - }{ - { - "empty data", types.CLIENT, func() { - data = []byte{} - }, false, - }, - { - "unspecified", types.UNSPECIFIED, func() { - path := solomachine.GetClientStatePath(counterpartyClientIdentifier) - data, err = types.ClientStateDataBytes(cdc, path, solomachine.ClientState()) - suite.Require().NoError(err) - }, false, - }, - { - "client", types.CLIENT, func() { - path := solomachine.GetClientStatePath(counterpartyClientIdentifier) - data, err = types.ClientStateDataBytes(cdc, path, solomachine.ClientState()) - suite.Require().NoError(err) - }, true, - }, - { - "bad client (provides consensus state data)", types.CLIENT, func() { - path := solomachine.GetConsensusStatePath(counterpartyClientIdentifier, clienttypes.NewHeight(0, 5)) - data, err = types.ConsensusStateDataBytes(cdc, path, solomachine.ConsensusState()) - suite.Require().NoError(err) - }, false, - }, - { - "consensus", types.CONSENSUS, func() { - path := solomachine.GetConsensusStatePath(counterpartyClientIdentifier, clienttypes.NewHeight(0, 5)) - data, err = types.ConsensusStateDataBytes(cdc, path, solomachine.ConsensusState()) - suite.Require().NoError(err) - - }, true, - }, - { - "bad consensus (provides client state data)", types.CONSENSUS, func() { - path := solomachine.GetClientStatePath(counterpartyClientIdentifier) - data, err = types.ClientStateDataBytes(cdc, path, solomachine.ClientState()) - suite.Require().NoError(err) - }, false, - }, - { - "connection", types.CONNECTION, func() { - counterparty := connectiontypes.NewCounterparty("clientB", testConnectionID, *prefix) - conn := connectiontypes.NewConnectionEnd(connectiontypes.OPEN, "clientA", counterparty, connectiontypes.ExportedVersionsToProto(connectiontypes.GetCompatibleVersions()), 0) - path := solomachine.GetConnectionStatePath("connectionID") - - data, err = types.ConnectionStateDataBytes(cdc, path, conn) - suite.Require().NoError(err) - - }, true, - }, - { - "bad connection (uses channel data)", types.CONNECTION, func() { - counterparty := channeltypes.NewCounterparty(testPortID, testChannelID) - ch := channeltypes.NewChannel(channeltypes.OPEN, channeltypes.ORDERED, counterparty, []string{testConnectionID}, "1.0.0") - path := solomachine.GetChannelStatePath("portID", "channelID") - - data, err = types.ChannelStateDataBytes(cdc, path, ch) - suite.Require().NoError(err) - }, false, - }, - { - "channel", types.CHANNEL, func() { - counterparty := channeltypes.NewCounterparty(testPortID, testChannelID) - ch := channeltypes.NewChannel(channeltypes.OPEN, channeltypes.ORDERED, counterparty, []string{testConnectionID}, "1.0.0") - path := solomachine.GetChannelStatePath("portID", "channelID") - - data, err = types.ChannelStateDataBytes(cdc, path, ch) - suite.Require().NoError(err) - }, true, - }, - { - "bad channel (uses connection data)", types.CHANNEL, func() { - counterparty := connectiontypes.NewCounterparty("clientB", testConnectionID, *prefix) - conn := connectiontypes.NewConnectionEnd(connectiontypes.OPEN, "clientA", counterparty, connectiontypes.ExportedVersionsToProto(connectiontypes.GetCompatibleVersions()), 0) - path := solomachine.GetConnectionStatePath("connectionID") - - data, err = types.ConnectionStateDataBytes(cdc, path, conn) - suite.Require().NoError(err) - - }, false, - }, - { - "packet commitment", types.PACKETCOMMITMENT, func() { - commitment := []byte("packet commitment") - path := solomachine.GetPacketCommitmentPath("portID", "channelID") - - data, err = types.PacketCommitmentDataBytes(cdc, path, commitment) - suite.Require().NoError(err) - }, true, - }, - { - "bad packet commitment (uses next seq recv)", types.PACKETCOMMITMENT, func() { - path := solomachine.GetNextSequenceRecvPath("portID", "channelID") - - data, err = types.NextSequenceRecvDataBytes(cdc, path, 10) - suite.Require().NoError(err) - }, false, - }, - { - "packet acknowledgement", types.PACKETACKNOWLEDGEMENT, func() { - commitment := []byte("packet acknowledgement") - path := solomachine.GetPacketAcknowledgementPath("portID", "channelID") - - data, err = types.PacketAcknowledgementDataBytes(cdc, path, commitment) - suite.Require().NoError(err) - }, true, - }, - { - "bad packet acknowledgement (uses next sequence recv)", types.PACKETACKNOWLEDGEMENT, func() { - path := solomachine.GetNextSequenceRecvPath("portID", "channelID") - - data, err = types.NextSequenceRecvDataBytes(cdc, path, 10) - suite.Require().NoError(err) - }, false, - }, - { - "packet acknowledgement absence", types.PACKETRECEIPTABSENCE, func() { - path := solomachine.GetPacketReceiptPath("portID", "channelID") - - data, err = types.PacketReceiptAbsenceDataBytes(cdc, path) - suite.Require().NoError(err) - }, true, - }, - { - "next sequence recv", types.NEXTSEQUENCERECV, func() { - path := solomachine.GetNextSequenceRecvPath("portID", "channelID") - - data, err = types.NextSequenceRecvDataBytes(cdc, path, 10) - suite.Require().NoError(err) - }, true, - }, - { - "bad next sequence recv (uses packet commitment)", types.NEXTSEQUENCERECV, func() { - commitment := []byte("packet commitment") - path := solomachine.GetPacketCommitmentPath("portID", "channelID") - - data, err = types.PacketCommitmentDataBytes(cdc, path, commitment) - suite.Require().NoError(err) - }, false, - }, - } - - for _, tc := range cases { - tc := tc - - suite.Run(tc.name, func() { - tc.malleate() - - data, err := types.UnmarshalDataByType(cdc, tc.dataType, data) - - if tc.expPass { - suite.Require().NoError(err) - suite.Require().NotNil(data) - } else { - suite.Require().Error(err) - suite.Require().Nil(data) - } - }) - } - } - -} diff --git a/modules/light-clients/06-solomachine/types/update.go b/modules/light-clients/06-solomachine/update.go similarity index 99% rename from modules/light-clients/06-solomachine/types/update.go rename to modules/light-clients/06-solomachine/update.go index e8c464772f7..1d903a6105a 100644 --- a/modules/light-clients/06-solomachine/types/update.go +++ b/modules/light-clients/06-solomachine/update.go @@ -1,4 +1,4 @@ -package types +package solomachine import ( "fmt" diff --git a/modules/light-clients/06-solomachine/types/update_test.go b/modules/light-clients/06-solomachine/update_test.go similarity index 66% rename from modules/light-clients/06-solomachine/types/update_test.go rename to modules/light-clients/06-solomachine/update_test.go index 223e468e87f..24dad99ab0b 100644 --- a/modules/light-clients/06-solomachine/types/update_test.go +++ b/modules/light-clients/06-solomachine/update_test.go @@ -1,4 +1,4 @@ -package types_test +package solomachine_test import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -7,19 +7,19 @@ import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + solomachine "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { var ( clientMsg exported.ClientMessage - clientState *types.ClientState + clientState *solomachine.ClientState ) // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { testCases := []struct { name string @@ -29,14 +29,14 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { { "successful header", func() { - clientMsg = solomachine.CreateHeader() + clientMsg = sm.CreateHeader() }, true, }, { "successful misbehaviour", func() { - clientMsg = solomachine.CreateMisbehaviour() + clientMsg = sm.CreateMisbehaviour() }, true, }, @@ -51,7 +51,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { "wrong sequence in header", func() { // store in temp before assigning to interface type - h := solomachine.CreateHeader() + h := sm.CreateHeader() h.Sequence++ clientMsg = h }, @@ -60,7 +60,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { { "invalid header Signature", func() { - h := solomachine.CreateHeader() + h := sm.CreateHeader() h.Signature = suite.GetInvalidProof() clientMsg = h }, false, @@ -68,7 +68,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { { "invalid timestamp in header", func() { - h := solomachine.CreateHeader() + h := sm.CreateHeader() h.Timestamp-- clientMsg = h }, false, @@ -77,8 +77,8 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { "signature uses wrong sequence", func() { - solomachine.Sequence++ - clientMsg = solomachine.CreateHeader() + sm.Sequence++ + clientMsg = sm.CreateHeader() }, false, }, @@ -86,13 +86,13 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { "signature uses new pubkey to sign", func() { // store in temp before assinging to interface type - cs := solomachine.ClientState() - h := solomachine.CreateHeader() + cs := sm.ClientState() + h := sm.CreateHeader() - publicKey, err := codectypes.NewAnyWithValue(solomachine.PublicKey) + publicKey, err := codectypes.NewAnyWithValue(sm.PublicKey) suite.NoError(err) - data := &types.HeaderData{ + data := &solomachine.HeaderData{ NewPubKey: publicKey, NewDiversifier: h.NewDiversifier, } @@ -101,18 +101,18 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { suite.Require().NoError(err) // generate invalid signature - signBytes := &types.SignBytes{ + signBytes := &solomachine.SignBytes{ Sequence: cs.Sequence, - Timestamp: solomachine.Time, - Diversifier: solomachine.Diversifier, - DataType: types.CLIENT, + Timestamp: sm.Time, + Diversifier: sm.Diversifier, + DataType: solomachine.CLIENT, Data: dataBz, } signBz, err := suite.chainA.Codec.Marshal(signBytes) suite.Require().NoError(err) - sig := solomachine.GenerateSignature(signBz) + sig := sm.GenerateSignature(signBz) suite.Require().NoError(err) h.Signature = sig @@ -126,13 +126,13 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { "signature signs over old pubkey", func() { // store in temp before assinging to interface type - cs := solomachine.ClientState() - oldPubKey := solomachine.PublicKey - h := solomachine.CreateHeader() + cs := sm.ClientState() + oldPubKey := sm.PublicKey + h := sm.CreateHeader() // generate invalid signature data := append(sdk.Uint64ToBigEndian(cs.Sequence), oldPubKey.Bytes()...) - sig := solomachine.GenerateSignature(data) + sig := sm.GenerateSignature(data) h.Signature = sig clientState = cs @@ -144,7 +144,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { "consensus state public key is nil - header", func() { clientState.ConsensusState.PublicKey = nil - clientMsg = solomachine.CreateHeader() + clientMsg = sm.CreateHeader() }, false, }, @@ -154,7 +154,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { tc := tc suite.Run(tc.name, func() { - clientState = solomachine.ClientState() + clientState = sm.ClientState() // setup test tc.setup() @@ -174,11 +174,11 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageHeader() { func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { var ( clientMsg exported.ClientMessage - clientState *types.ClientState + clientState *solomachine.ClientState ) // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { testCases := []struct { name string @@ -188,16 +188,16 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { { "successful misbehaviour", func() { - clientMsg = solomachine.CreateMisbehaviour() + clientMsg = sm.CreateMisbehaviour() }, true, }, { "old misbehaviour is successful (timestamp is less than current consensus state)", func() { - clientState = solomachine.ClientState() - solomachine.Time = solomachine.Time - 5 - clientMsg = solomachine.CreateMisbehaviour() + clientState = sm.ClientState() + sm.Time = sm.Time - 5 + clientMsg = sm.CreateMisbehaviour() }, true, }, { @@ -211,14 +211,14 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { "consensus state pubkey is nil", func() { clientState.ConsensusState.PublicKey = nil - clientMsg = solomachine.CreateMisbehaviour() + clientMsg = sm.CreateMisbehaviour() }, false, }, { "invalid SignatureOne SignatureData", func() { - m := solomachine.CreateMisbehaviour() + m := sm.CreateMisbehaviour() m.SignatureOne.Signature = suite.GetInvalidProof() clientMsg = m @@ -227,7 +227,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { { "invalid SignatureTwo SignatureData", func() { - m := solomachine.CreateMisbehaviour() + m := sm.CreateMisbehaviour() m.SignatureTwo.Signature = suite.GetInvalidProof() clientMsg = m @@ -236,7 +236,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { { "invalid SignatureOne timestamp", func() { - m := solomachine.CreateMisbehaviour() + m := sm.CreateMisbehaviour() m.SignatureOne.Timestamp = 1000000000000 clientMsg = m @@ -245,7 +245,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { { "invalid SignatureTwo timestamp", func() { - m := solomachine.CreateMisbehaviour() + m := sm.CreateMisbehaviour() m.SignatureTwo.Timestamp = 1000000000000 clientMsg = m @@ -255,21 +255,21 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { "invalid first signature data", func() { // store in temp before assigning to interface type - m := solomachine.CreateMisbehaviour() + m := sm.CreateMisbehaviour() msg := []byte("DATA ONE") - signBytes := &types.SignBytes{ - Sequence: solomachine.Sequence + 1, - Timestamp: solomachine.Time, - Diversifier: solomachine.Diversifier, - DataType: types.CLIENT, + signBytes := &solomachine.SignBytes{ + Sequence: sm.Sequence + 1, + Timestamp: sm.Time, + Diversifier: sm.Diversifier, + DataType: solomachine.CLIENT, Data: msg, } data, err := suite.chainA.Codec.Marshal(signBytes) suite.Require().NoError(err) - sig := solomachine.GenerateSignature(data) + sig := sm.GenerateSignature(data) m.SignatureOne.Signature = sig m.SignatureOne.Data = msg @@ -281,21 +281,21 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { "invalid second signature data", func() { // store in temp before assigning to interface type - m := solomachine.CreateMisbehaviour() + m := sm.CreateMisbehaviour() msg := []byte("DATA TWO") - signBytes := &types.SignBytes{ - Sequence: solomachine.Sequence + 1, - Timestamp: solomachine.Time, - Diversifier: solomachine.Diversifier, - DataType: types.CLIENT, + signBytes := &solomachine.SignBytes{ + Sequence: sm.Sequence + 1, + Timestamp: sm.Time, + Diversifier: sm.Diversifier, + DataType: solomachine.CLIENT, Data: msg, } data, err := suite.chainA.Codec.Marshal(signBytes) suite.Require().NoError(err) - sig := solomachine.GenerateSignature(data) + sig := sm.GenerateSignature(data) m.SignatureTwo.Signature = sig m.SignatureTwo.Data = msg @@ -306,11 +306,11 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { { "wrong pubkey generates first signature", func() { - badMisbehaviour := solomachine.CreateMisbehaviour() + badMisbehaviour := sm.CreateMisbehaviour() // update public key to a new one - solomachine.CreateHeader() - m := solomachine.CreateMisbehaviour() + sm.CreateHeader() + m := sm.CreateMisbehaviour() // set SignatureOne to use the wrong signature m.SignatureOne = badMisbehaviour.SignatureOne @@ -320,11 +320,11 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { { "wrong pubkey generates second signature", func() { - badMisbehaviour := solomachine.CreateMisbehaviour() + badMisbehaviour := sm.CreateMisbehaviour() // update public key to a new one - solomachine.CreateHeader() - m := solomachine.CreateMisbehaviour() + sm.CreateHeader() + m := sm.CreateMisbehaviour() // set SignatureTwo to use the wrong signature m.SignatureTwo = badMisbehaviour.SignatureTwo @@ -336,23 +336,23 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { func() { // store in temp before assigning to interface type - m := solomachine.CreateMisbehaviour() + m := sm.CreateMisbehaviour() // Signature One msg := []byte("DATA ONE") // sequence used is plus 1 - signBytes := &types.SignBytes{ - Sequence: solomachine.Sequence + 1, - Timestamp: solomachine.Time, - Diversifier: solomachine.Diversifier, - DataType: types.CLIENT, + signBytes := &solomachine.SignBytes{ + Sequence: sm.Sequence + 1, + Timestamp: sm.Time, + Diversifier: sm.Diversifier, + DataType: solomachine.CLIENT, Data: msg, } data, err := suite.chainA.Codec.Marshal(signBytes) suite.Require().NoError(err) - sig := solomachine.GenerateSignature(data) + sig := sm.GenerateSignature(data) m.SignatureOne.Signature = sig m.SignatureOne.Data = msg @@ -361,17 +361,17 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { msg = []byte("DATA TWO") // sequence used is minus 1 - signBytes = &types.SignBytes{ - Sequence: solomachine.Sequence - 1, - Timestamp: solomachine.Time, - Diversifier: solomachine.Diversifier, - DataType: types.CLIENT, + signBytes = &solomachine.SignBytes{ + Sequence: sm.Sequence - 1, + Timestamp: sm.Time, + Diversifier: sm.Diversifier, + DataType: solomachine.CLIENT, Data: msg, } data, err = suite.chainA.Codec.Marshal(signBytes) suite.Require().NoError(err) - sig = solomachine.GenerateSignature(data) + sig = sm.GenerateSignature(data) m.SignatureTwo.Signature = sig m.SignatureTwo.Data = msg @@ -386,7 +386,7 @@ func (suite *SoloMachineTestSuite) TestVerifyClientMessageMisbehaviour() { tc := tc suite.Run(tc.name, func() { - clientState = solomachine.ClientState() + clientState = sm.ClientState() // setup test tc.setup() @@ -410,7 +410,7 @@ func (suite *SoloMachineTestSuite) TestUpdateState() { ) // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { testCases := []struct { name string @@ -420,16 +420,16 @@ func (suite *SoloMachineTestSuite) TestUpdateState() { { "successful update", func() { - clientState = solomachine.ClientState() - clientMsg = solomachine.CreateHeader() + clientState = sm.ClientState() + clientMsg = sm.CreateHeader() }, true, }, { "invalid type misbehaviour", func() { - clientState = solomachine.ClientState() - clientMsg = solomachine.CreateMisbehaviour() + clientState = sm.ClientState() + clientMsg = sm.CreateMisbehaviour() }, false, }, @@ -451,13 +451,13 @@ func (suite *SoloMachineTestSuite) TestUpdateState() { suite.Require().Len(consensusHeights, 1) suite.Require().Equal(uint64(0), consensusHeights[0].GetRevisionNumber()) - suite.Require().Equal(newClientState.(*types.ClientState).Sequence, consensusHeights[0].GetRevisionHeight()) + suite.Require().Equal(newClientState.(*solomachine.ClientState).Sequence, consensusHeights[0].GetRevisionHeight()) - suite.Require().False(newClientState.(*types.ClientState).IsFrozen) - suite.Require().Equal(clientMsg.(*types.Header).Sequence+1, newClientState.(*types.ClientState).Sequence) - suite.Require().Equal(clientMsg.(*types.Header).NewPublicKey, newClientState.(*types.ClientState).ConsensusState.PublicKey) - suite.Require().Equal(clientMsg.(*types.Header).NewDiversifier, newClientState.(*types.ClientState).ConsensusState.Diversifier) - suite.Require().Equal(clientMsg.(*types.Header).Timestamp, newClientState.(*types.ClientState).ConsensusState.Timestamp) + suite.Require().False(newClientState.(*solomachine.ClientState).IsFrozen) + suite.Require().Equal(clientMsg.(*solomachine.Header).Sequence+1, newClientState.(*solomachine.ClientState).Sequence) + suite.Require().Equal(clientMsg.(*solomachine.Header).NewPublicKey, newClientState.(*solomachine.ClientState).ConsensusState.PublicKey) + suite.Require().Equal(clientMsg.(*solomachine.Header).NewDiversifier, newClientState.(*solomachine.ClientState).ConsensusState.Diversifier) + suite.Require().Equal(clientMsg.(*solomachine.Header).Timestamp, newClientState.(*solomachine.ClientState).ConsensusState.Timestamp) } else { suite.Require().Panics(func() { clientState.UpdateState(suite.chainA.GetContext(), suite.chainA.Codec, suite.store, clientMsg) @@ -475,7 +475,7 @@ func (suite *SoloMachineTestSuite) TestCheckForMisbehaviour() { ) // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { testCases := []struct { name string malleate func() @@ -484,14 +484,14 @@ func (suite *SoloMachineTestSuite) TestCheckForMisbehaviour() { { "success", func() { - clientMsg = solomachine.CreateMisbehaviour() + clientMsg = sm.CreateMisbehaviour() }, true, }, { "normal header returns false", func() { - clientMsg = solomachine.CreateHeader() + clientMsg = sm.CreateHeader() }, false, }, @@ -501,7 +501,7 @@ func (suite *SoloMachineTestSuite) TestCheckForMisbehaviour() { tc := tc suite.Run(tc.name, func() { - clientState := solomachine.ClientState() + clientState := sm.ClientState() tc.malleate() @@ -520,7 +520,7 @@ func (suite *SoloMachineTestSuite) TestCheckForMisbehaviour() { func (suite *SoloMachineTestSuite) TestUpdateStateOnMisbehaviour() { // test singlesig and multisig public keys - for _, solomachine := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { + for _, sm := range []*ibctesting.Solomachine{suite.solomachine, suite.solomachineMulti} { testCases := []struct { name string malleate func() @@ -537,7 +537,7 @@ func (suite *SoloMachineTestSuite) TestUpdateStateOnMisbehaviour() { tc := tc suite.Run(tc.name, func() { - clientState := solomachine.ClientState() + clientState := sm.ClientState() tc.malleate() @@ -549,7 +549,7 @@ func (suite *SoloMachineTestSuite) TestUpdateStateOnMisbehaviour() { newClientState := clienttypes.MustUnmarshalClientState(suite.chainA.Codec, clientStateBz) - suite.Require().True(newClientState.(*types.ClientState).IsFrozen) + suite.Require().True(newClientState.(*solomachine.ClientState).IsFrozen) } }) } diff --git a/modules/light-clients/07-tendermint/types/client_state.go b/modules/light-clients/07-tendermint/client_state.go similarity index 99% rename from modules/light-clients/07-tendermint/types/client_state.go rename to modules/light-clients/07-tendermint/client_state.go index 1593f76c959..27a78768571 100644 --- a/modules/light-clients/07-tendermint/types/client_state.go +++ b/modules/light-clients/07-tendermint/client_state.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( "strings" diff --git a/modules/light-clients/07-tendermint/types/client_state_test.go b/modules/light-clients/07-tendermint/client_state_test.go similarity index 86% rename from modules/light-clients/07-tendermint/types/client_state_test.go rename to modules/light-clients/07-tendermint/client_state_test.go index 56bbf0909b3..f69aecd969d 100644 --- a/modules/light-clients/07-tendermint/types/client_state_test.go +++ b/modules/light-clients/07-tendermint/client_state_test.go @@ -1,4 +1,4 @@ -package types_test +package tendermint_test import ( "time" @@ -12,7 +12,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + tendermint "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibcmock "github.com/cosmos/ibc-go/v3/testing/mock" ) @@ -30,7 +30,7 @@ var ( func (suite *TendermintTestSuite) TestStatus() { var ( path *ibctesting.Path - clientState *types.ClientState + clientState *tendermint.ClientState ) testCases := []struct { @@ -57,7 +57,7 @@ func (suite *TendermintTestSuite) TestStatus() { suite.coordinator.SetupClients(path) clientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID) - clientState = path.EndpointA.GetClientState().(*types.ClientState) + clientState = path.EndpointA.GetClientState().(*tendermint.ClientState) tc.malleate() @@ -70,22 +70,22 @@ func (suite *TendermintTestSuite) TestStatus() { func (suite *TendermintTestSuite) TestValidate() { testCases := []struct { name string - clientState *types.ClientState + clientState *tendermint.ClientState expPass bool }{ { name: "valid client", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: tendermint.NewClientState(chainID, tendermint.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: true, }, { name: "valid client with nil upgrade path", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), nil, false, false), + clientState: tendermint.NewClientState(chainID, tendermint.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), nil, false, false), expPass: true, }, { name: "invalid chainID", - clientState: types.NewClientState(" ", types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: tendermint.NewClientState(" ", tendermint.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { @@ -93,7 +93,7 @@ func (suite *TendermintTestSuite) TestValidate() { // Do not only fix the test, fix the code! // https://github.com/cosmos/ibc-go/issues/177 name: "valid chainID - chainID validation failed for chainID of length 50! ", - clientState: types.NewClientState(fiftyCharChainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: tendermint.NewClientState(fiftyCharChainID, tendermint.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: true, }, { @@ -101,52 +101,52 @@ func (suite *TendermintTestSuite) TestValidate() { // Do not only fix the test, fix the code! // https://github.com/cosmos/ibc-go/issues/177 name: "invalid chainID - chainID validation did not fail for chainID of length 51! ", - clientState: types.NewClientState(fiftyOneCharChainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: tendermint.NewClientState(fiftyOneCharChainID, tendermint.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "invalid trust level", - clientState: types.NewClientState(chainID, types.Fraction{Numerator: 0, Denominator: 1}, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: tendermint.NewClientState(chainID, tendermint.Fraction{Numerator: 0, Denominator: 1}, trustingPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "invalid trusting period", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, 0, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: tendermint.NewClientState(chainID, tendermint.DefaultTrustLevel, 0, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "invalid unbonding period", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, 0, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: tendermint.NewClientState(chainID, tendermint.DefaultTrustLevel, trustingPeriod, 0, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "invalid max clock drift", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, 0, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: tendermint.NewClientState(chainID, tendermint.DefaultTrustLevel, trustingPeriod, ubdPeriod, 0, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "invalid revision number", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: tendermint.NewClientState(chainID, tendermint.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.NewHeight(1, 1), commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "invalid revision height", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: tendermint.NewClientState(chainID, tendermint.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, clienttypes.ZeroHeight(), commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "trusting period not less than unbonding period", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), + clientState: tendermint.NewClientState(chainID, tendermint.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, commitmenttypes.GetSDKSpecs(), upgradePath, false, false), expPass: false, }, { name: "proof specs is nil", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, nil, upgradePath, false, false), + clientState: tendermint.NewClientState(chainID, tendermint.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, nil, upgradePath, false, false), expPass: false, }, { name: "proof specs contains nil", - clientState: types.NewClientState(chainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, []*ics23.ProofSpec{ics23.TendermintSpec, nil}, upgradePath, false, false), + clientState: tendermint.NewClientState(chainID, tendermint.DefaultTrustLevel, ubdPeriod, ubdPeriod, maxClockDrift, height, []*ics23.ProofSpec{ics23.TendermintSpec, nil}, upgradePath, false, false), expPass: false, }, } @@ -170,7 +170,7 @@ func (suite *TendermintTestSuite) TestInitialize() { }{ { name: "valid consensus", - consensusState: &types.ConsensusState{}, + consensusState: &tendermint.ConsensusState{}, expPass: true, }, { @@ -232,7 +232,7 @@ func (suite *TendermintTestSuite) TestVerifyMembership() { proof, proofHeight = suite.chainB.QueryProof(key) - consensusState := testingpath.EndpointB.GetConsensusState(testingpath.EndpointB.GetClientState().GetLatestHeight()).(*types.ConsensusState) + consensusState := testingpath.EndpointB.GetConsensusState(testingpath.EndpointB.GetClientState().GetLatestHeight()).(*tendermint.ConsensusState) value, err = suite.chainB.Codec.MarshalInterface(consensusState) suite.Require().NoError(err) }, @@ -442,13 +442,13 @@ func (suite *TendermintTestSuite) TestVerifyMembership() { proof, proofHeight = suite.chainB.QueryProof(key) - clientState := testingpath.EndpointB.GetClientState().(*types.ClientState) + clientState := testingpath.EndpointB.GetClientState().(*tendermint.ClientState) value, err = suite.chainB.Codec.MarshalInterface(clientState) suite.Require().NoError(err) tc.malleate() // make changes as necessary - clientState = testingpath.EndpointA.GetClientState().(*types.ClientState) + clientState = testingpath.EndpointA.GetClientState().(*tendermint.ClientState) ctx := suite.chainA.GetContext() store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(ctx, testingpath.EndpointA.ClientID) @@ -680,7 +680,7 @@ func (suite *TendermintTestSuite) TestVerifyNonMembership() { tc.malleate() // make changes as necessary - clientState := testingpath.EndpointA.GetClientState().(*types.ClientState) + clientState := testingpath.EndpointA.GetClientState().(*tendermint.ClientState) ctx := suite.chainA.GetContext() store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(ctx, testingpath.EndpointA.ClientID) diff --git a/modules/light-clients/07-tendermint/types/codec.go b/modules/light-clients/07-tendermint/codec.go similarity index 97% rename from modules/light-clients/07-tendermint/types/codec.go rename to modules/light-clients/07-tendermint/codec.go index 0652321ba16..931f66ca1b4 100644 --- a/modules/light-clients/07-tendermint/types/codec.go +++ b/modules/light-clients/07-tendermint/codec.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( codectypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/modules/light-clients/07-tendermint/types/consensus_state.go b/modules/light-clients/07-tendermint/consensus_state.go similarity index 99% rename from modules/light-clients/07-tendermint/types/consensus_state.go rename to modules/light-clients/07-tendermint/consensus_state.go index aa475daa733..10a551f36b1 100644 --- a/modules/light-clients/07-tendermint/types/consensus_state.go +++ b/modules/light-clients/07-tendermint/consensus_state.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( "time" diff --git a/modules/light-clients/07-tendermint/types/consensus_state_test.go b/modules/light-clients/07-tendermint/consensus_state_test.go similarity index 81% rename from modules/light-clients/07-tendermint/types/consensus_state_test.go rename to modules/light-clients/07-tendermint/consensus_state_test.go index f45a4a5d24d..b2b73ca4b4a 100644 --- a/modules/light-clients/07-tendermint/types/consensus_state_test.go +++ b/modules/light-clients/07-tendermint/consensus_state_test.go @@ -1,49 +1,49 @@ -package types_test +package tendermint_test import ( "time" commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + tendermint "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ) func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() { testCases := []struct { msg string - consensusState *types.ConsensusState + consensusState *tendermint.ConsensusState expectPass bool }{ {"success", - &types.ConsensusState{ + &tendermint.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")), NextValidatorsHash: suite.valsHash, }, true}, {"success with sentinel", - &types.ConsensusState{ + &tendermint.ConsensusState{ Timestamp: suite.now, - Root: commitmenttypes.NewMerkleRoot([]byte(types.SentinelRoot)), + Root: commitmenttypes.NewMerkleRoot([]byte(tendermint.SentinelRoot)), NextValidatorsHash: suite.valsHash, }, true}, {"root is nil", - &types.ConsensusState{ + &tendermint.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.MerkleRoot{}, NextValidatorsHash: suite.valsHash, }, false}, {"root is empty", - &types.ConsensusState{ + &tendermint.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.MerkleRoot{}, NextValidatorsHash: suite.valsHash, }, false}, {"nextvalshash is invalid", - &types.ConsensusState{ + &tendermint.ConsensusState{ Timestamp: suite.now, Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")), NextValidatorsHash: []byte("hi"), @@ -51,7 +51,7 @@ func (suite *TendermintTestSuite) TestConsensusStateValidateBasic() { false}, {"timestamp is zero", - &types.ConsensusState{ + &tendermint.ConsensusState{ Timestamp: time.Time{}, Root: commitmenttypes.NewMerkleRoot([]byte("app_hash")), NextValidatorsHash: suite.valsHash, diff --git a/modules/light-clients/07-tendermint/types/errors.go b/modules/light-clients/07-tendermint/errors.go similarity index 98% rename from modules/light-clients/07-tendermint/types/errors.go rename to modules/light-clients/07-tendermint/errors.go index 7b087e41af5..2839beb5291 100644 --- a/modules/light-clients/07-tendermint/types/errors.go +++ b/modules/light-clients/07-tendermint/errors.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( sdkerrors "github.com/cosmos/cosmos-sdk/types/errors" diff --git a/modules/light-clients/07-tendermint/types/fraction.go b/modules/light-clients/07-tendermint/fraction.go similarity index 97% rename from modules/light-clients/07-tendermint/types/fraction.go rename to modules/light-clients/07-tendermint/fraction.go index e445f19ba6f..772c6d9c171 100644 --- a/modules/light-clients/07-tendermint/types/fraction.go +++ b/modules/light-clients/07-tendermint/fraction.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( tmmath "github.com/tendermint/tendermint/libs/math" diff --git a/modules/light-clients/07-tendermint/types/genesis.go b/modules/light-clients/07-tendermint/genesis.go similarity index 97% rename from modules/light-clients/07-tendermint/types/genesis.go rename to modules/light-clients/07-tendermint/genesis.go index 82a996d3696..ea47828a075 100644 --- a/modules/light-clients/07-tendermint/types/genesis.go +++ b/modules/light-clients/07-tendermint/genesis.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( sdk "github.com/cosmos/cosmos-sdk/types" diff --git a/modules/light-clients/07-tendermint/types/genesis_test.go b/modules/light-clients/07-tendermint/genesis_test.go similarity index 67% rename from modules/light-clients/07-tendermint/types/genesis_test.go rename to modules/light-clients/07-tendermint/genesis_test.go index 703cf5ce996..9feb66372cf 100644 --- a/modules/light-clients/07-tendermint/types/genesis_test.go +++ b/modules/light-clients/07-tendermint/genesis_test.go @@ -1,10 +1,10 @@ -package types_test +package tendermint_test import ( sdk "github.com/cosmos/cosmos-sdk/types" clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + tendermint "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) @@ -19,26 +19,26 @@ func (suite *TendermintTestSuite) TestExportMetadata() { clientState := path.EndpointA.GetClientState() height := clientState.GetLatestHeight() - initIteration := types.GetIterationKey(clientStore, height) + initIteration := tendermint.GetIterationKey(clientStore, height) suite.Require().NotEqual(0, len(initIteration)) - initProcessedTime, found := types.GetProcessedTime(clientStore, height) + initProcessedTime, found := tendermint.GetProcessedTime(clientStore, height) suite.Require().True(found) - initProcessedHeight, found := types.GetProcessedHeight(clientStore, height) + initProcessedHeight, found := tendermint.GetProcessedHeight(clientStore, height) suite.Require().True(found) gm := clientState.ExportMetadata(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID)) suite.Require().NotNil(gm, "client with metadata returned nil exported metadata") suite.Require().Len(gm, 3, "exported metadata has unexpected length") - suite.Require().Equal(types.ProcessedHeightKey(height), gm[0].GetKey(), "metadata has unexpected key") + suite.Require().Equal(tendermint.ProcessedHeightKey(height), gm[0].GetKey(), "metadata has unexpected key") actualProcessedHeight, err := clienttypes.ParseHeight(string(gm[0].GetValue())) suite.Require().NoError(err) suite.Require().Equal(initProcessedHeight, actualProcessedHeight, "metadata has unexpected value") - suite.Require().Equal(types.ProcessedTimeKey(height), gm[1].GetKey(), "metadata has unexpected key") + suite.Require().Equal(tendermint.ProcessedTimeKey(height), gm[1].GetKey(), "metadata has unexpected key") suite.Require().Equal(initProcessedTime, sdk.BigEndianToUint64(gm[1].GetValue()), "metadata has unexpected value") - suite.Require().Equal(types.IterationKey(height), gm[2].GetKey(), "metadata has unexpected key") + suite.Require().Equal(tendermint.IterationKey(height), gm[2].GetKey(), "metadata has unexpected key") suite.Require().Equal(initIteration, gm[2].GetValue(), "metadata has unexpected value") // test updating client and exporting metadata @@ -48,11 +48,11 @@ func (suite *TendermintTestSuite) TestExportMetadata() { clientState = path.EndpointA.GetClientState() updateHeight := clientState.GetLatestHeight() - iteration := types.GetIterationKey(clientStore, updateHeight) + iteration := tendermint.GetIterationKey(clientStore, updateHeight) suite.Require().NotEqual(0, len(initIteration)) - processedTime, found := types.GetProcessedTime(clientStore, updateHeight) + processedTime, found := tendermint.GetProcessedTime(clientStore, updateHeight) suite.Require().True(found) - processedHeight, found := types.GetProcessedHeight(clientStore, updateHeight) + processedHeight, found := tendermint.GetProcessedHeight(clientStore, updateHeight) suite.Require().True(found) gm = clientState.ExportMetadata(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID)) @@ -63,27 +63,27 @@ func (suite *TendermintTestSuite) TestExportMetadata() { // initProcessedHeight, initProcessedTime, processedHeight, processedTime, initIteration, iteration // check init processed height and time - suite.Require().Equal(types.ProcessedHeightKey(height), gm[0].GetKey(), "metadata has unexpected key") + suite.Require().Equal(tendermint.ProcessedHeightKey(height), gm[0].GetKey(), "metadata has unexpected key") actualProcessedHeight, err = clienttypes.ParseHeight(string(gm[0].GetValue())) suite.Require().NoError(err) suite.Require().Equal(initProcessedHeight, actualProcessedHeight, "metadata has unexpected value") - suite.Require().Equal(types.ProcessedTimeKey(height), gm[1].GetKey(), "metadata has unexpected key") + suite.Require().Equal(tendermint.ProcessedTimeKey(height), gm[1].GetKey(), "metadata has unexpected key") suite.Require().Equal(initProcessedTime, sdk.BigEndianToUint64(gm[1].GetValue()), "metadata has unexpected value") // check processed height and time after update - suite.Require().Equal(types.ProcessedHeightKey(updateHeight), gm[2].GetKey(), "metadata has unexpected key") + suite.Require().Equal(tendermint.ProcessedHeightKey(updateHeight), gm[2].GetKey(), "metadata has unexpected key") actualProcessedHeight, err = clienttypes.ParseHeight(string(gm[2].GetValue())) suite.Require().NoError(err) suite.Require().Equal(processedHeight, actualProcessedHeight, "metadata has unexpected value") - suite.Require().Equal(types.ProcessedTimeKey(updateHeight), gm[3].GetKey(), "metadata has unexpected key") + suite.Require().Equal(tendermint.ProcessedTimeKey(updateHeight), gm[3].GetKey(), "metadata has unexpected key") suite.Require().Equal(processedTime, sdk.BigEndianToUint64(gm[3].GetValue()), "metadata has unexpected value") // check iteration keys - suite.Require().Equal(types.IterationKey(height), gm[4].GetKey(), "metadata has unexpected key") + suite.Require().Equal(tendermint.IterationKey(height), gm[4].GetKey(), "metadata has unexpected key") suite.Require().Equal(initIteration, gm[4].GetValue(), "metadata has unexpected value") - suite.Require().Equal(types.IterationKey(updateHeight), gm[5].GetKey(), "metadata has unexpected key") + suite.Require().Equal(tendermint.IterationKey(updateHeight), gm[5].GetKey(), "metadata has unexpected key") suite.Require().Equal(iteration, gm[5].GetValue(), "metadata has unexpected value") } diff --git a/modules/light-clients/07-tendermint/types/header.go b/modules/light-clients/07-tendermint/header.go similarity index 99% rename from modules/light-clients/07-tendermint/types/header.go rename to modules/light-clients/07-tendermint/header.go index b5c51ec2cbf..ee57b2c085f 100644 --- a/modules/light-clients/07-tendermint/types/header.go +++ b/modules/light-clients/07-tendermint/header.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( "bytes" diff --git a/modules/light-clients/07-tendermint/types/header_test.go b/modules/light-clients/07-tendermint/header_test.go similarity index 94% rename from modules/light-clients/07-tendermint/types/header_test.go rename to modules/light-clients/07-tendermint/header_test.go index f57776c092f..b1df2128a1f 100644 --- a/modules/light-clients/07-tendermint/types/header_test.go +++ b/modules/light-clients/07-tendermint/header_test.go @@ -1,4 +1,4 @@ -package types_test +package tendermint_test import ( "time" @@ -7,7 +7,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + tendermint "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ) func (suite *TendermintTestSuite) TestGetHeight() { @@ -22,7 +22,7 @@ func (suite *TendermintTestSuite) TestGetTime() { func (suite *TendermintTestSuite) TestHeaderValidateBasic() { var ( - header *types.Header + header *tendermint.Header ) testCases := []struct { name string diff --git a/modules/light-clients/07-tendermint/types/misbehaviour.go b/modules/light-clients/07-tendermint/misbehaviour.go similarity index 99% rename from modules/light-clients/07-tendermint/types/misbehaviour.go rename to modules/light-clients/07-tendermint/misbehaviour.go index e2407e6830d..41eb6a11efd 100644 --- a/modules/light-clients/07-tendermint/types/misbehaviour.go +++ b/modules/light-clients/07-tendermint/misbehaviour.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( "time" diff --git a/modules/light-clients/07-tendermint/types/misbehaviour_handle.go b/modules/light-clients/07-tendermint/misbehaviour_handle.go similarity index 99% rename from modules/light-clients/07-tendermint/types/misbehaviour_handle.go rename to modules/light-clients/07-tendermint/misbehaviour_handle.go index ea2ab19cc47..08ddfcffecb 100644 --- a/modules/light-clients/07-tendermint/types/misbehaviour_handle.go +++ b/modules/light-clients/07-tendermint/misbehaviour_handle.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( "bytes" diff --git a/modules/light-clients/07-tendermint/types/misbehaviour_handle_test.go b/modules/light-clients/07-tendermint/misbehaviour_handle_test.go similarity index 95% rename from modules/light-clients/07-tendermint/types/misbehaviour_handle_test.go rename to modules/light-clients/07-tendermint/misbehaviour_handle_test.go index dc8c07c1bcd..a8bfa024862 100644 --- a/modules/light-clients/07-tendermint/types/misbehaviour_handle_test.go +++ b/modules/light-clients/07-tendermint/misbehaviour_handle_test.go @@ -1,4 +1,4 @@ -package types_test +package tendermint_test import ( "fmt" @@ -9,8 +9,8 @@ import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - smtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + smtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" + tendermint "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibctestingmock "github.com/cosmos/ibc-go/v3/testing/mock" ) @@ -50,7 +50,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -64,7 +64,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { trustedVals, found := suite.chainB.GetValsAtHeight(int64(trustedHeight.RevisionHeight) + 1) suite.Require().True(found) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height+3, trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -78,7 +78,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { trustedVals, found := suite.chainB.GetValsAtHeight(int64(trustedHeight.RevisionHeight) + 1) suite.Require().True(found) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height+3, trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Hour), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -92,7 +92,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { trustedVals, found := suite.chainB.GetValsAtHeight(int64(trustedHeight.RevisionHeight) + 1) suite.Require().True(found) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height+1, trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height+1, trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -113,7 +113,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { trustedVals2, found := suite.chainB.GetValsAtHeight(int64(trustedHeight2.RevisionHeight) + 1) suite.Require().True(found) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight1, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals1, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight2, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals2, suite.chainB.Signers), } @@ -134,7 +134,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -156,7 +156,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { futureRevision := fmt.Sprintf("%s-%d", strings.TrimSuffix(suite.chainB.ChainID, fmt.Sprintf("-%d", clienttypes.ParseChainID(suite.chainB.ChainID))), height.GetRevisionNumber()+1) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(futureRevision, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(futureRevision, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -176,7 +176,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -200,7 +200,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { bothSigners := suite.chainB.Signers bothSigners[altValSet.Proposer.Address.String()] = altPrivVal - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), bothValSet, suite.chainB.NextVals, trustedVals, bothSigners), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, bothValSet, suite.chainB.NextVals, trustedVals, bothSigners), } @@ -219,7 +219,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) misbehaviourHeader := suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: misbehaviourHeader, Header2: misbehaviourHeader, } @@ -232,7 +232,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { trustedVals, found := suite.chainB.GetValsAtHeight(int64(trustedHeight.RevisionHeight) + 1) suite.Require().True(found) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height+3, trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -250,7 +250,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader("evmos", int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader("evmos", int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -266,7 +266,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, altValSet, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, altValSet, suite.chainB.Signers), } @@ -279,7 +279,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { trustedVals, found := suite.chainB.GetValsAtHeight(int64(trustedHeight.RevisionHeight) + 1) suite.Require().True(found) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight.Increment().(clienttypes.Height), suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -304,7 +304,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { suite.chainA.ExpireClient(path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -322,7 +322,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), altValSet, suite.chainB.NextVals, trustedVals, altSigners), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -340,7 +340,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, altValSet, suite.chainB.NextVals, trustedVals, altSigners), } @@ -358,7 +358,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviour() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), altValSet, suite.chainB.NextVals, trustedVals, altSigners), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, altValSet, suite.chainB.NextVals, trustedVals, altSigners), } @@ -433,7 +433,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -447,7 +447,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { trustedVals, found := suite.chainB.GetValsAtHeight(int64(trustedHeight.RevisionHeight) + 1) suite.Require().True(found) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height+3, trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -461,7 +461,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { trustedVals, found := suite.chainB.GetValsAtHeight(int64(trustedHeight.RevisionHeight) + 1) suite.Require().True(found) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height+3, trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Hour), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -475,7 +475,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { trustedVals, found := suite.chainB.GetValsAtHeight(int64(trustedHeight.RevisionHeight) + 1) suite.Require().True(found) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height+1, trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height+1, trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -496,7 +496,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { trustedVals2, found := suite.chainB.GetValsAtHeight(int64(trustedHeight2.RevisionHeight) + 1) suite.Require().True(found) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight1, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals1, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight2, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals2, suite.chainB.Signers), } @@ -521,7 +521,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { bothSigners := suite.chainB.Signers bothSigners[altValSet.Proposer.Address.String()] = altPrivVal - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), bothValSet, suite.chainB.NextVals, trustedVals, bothSigners), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, bothValSet, suite.chainB.NextVals, trustedVals, bothSigners), } @@ -540,7 +540,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) misbehaviourHeader := suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: misbehaviourHeader, Header2: misbehaviourHeader, } @@ -553,7 +553,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { trustedVals, found := suite.chainB.GetValsAtHeight(int64(trustedHeight.RevisionHeight) + 1) suite.Require().True(found) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height+3, trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -571,7 +571,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader("evmos", int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader("evmos", int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -587,7 +587,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, altValSet, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, altValSet, suite.chainB.Signers), } @@ -600,7 +600,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { trustedVals, found := suite.chainB.GetValsAtHeight(int64(trustedHeight.RevisionHeight) + 1) suite.Require().True(found) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight.Increment().(clienttypes.Height), suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, suite.chainB.CurrentHeader.Height, trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -625,7 +625,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { suite.chainA.ExpireClient(path.EndpointA.ClientConfig.(*ibctesting.TendermintConfig).TrustingPeriod) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -643,7 +643,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), altValSet, suite.chainB.NextVals, trustedVals, altSigners), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), } @@ -661,7 +661,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), suite.chainB.Vals, suite.chainB.NextVals, trustedVals, suite.chainB.Signers), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, altValSet, suite.chainB.NextVals, trustedVals, altSigners), } @@ -679,7 +679,7 @@ func (suite *TendermintTestSuite) TestVerifyMisbehaviourNonRevisionChainID() { height := path.EndpointA.GetClientState().GetLatestHeight().(clienttypes.Height) - misbehaviour = &types.Misbehaviour{ + misbehaviour = &tendermint.Misbehaviour{ Header1: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time.Add(time.Minute), altValSet, suite.chainB.NextVals, trustedVals, altSigners), Header2: suite.chainB.CreateTMClientHeader(suite.chainB.ChainID, int64(height.RevisionHeight), trustedHeight, suite.chainB.CurrentHeader.Time, altValSet, suite.chainB.NextVals, trustedVals, altSigners), } diff --git a/modules/light-clients/07-tendermint/types/misbehaviour_test.go b/modules/light-clients/07-tendermint/misbehaviour_test.go similarity index 81% rename from modules/light-clients/07-tendermint/types/misbehaviour_test.go rename to modules/light-clients/07-tendermint/misbehaviour_test.go index fdd51df4e53..41aa89cbdec 100644 --- a/modules/light-clients/07-tendermint/types/misbehaviour_test.go +++ b/modules/light-clients/07-tendermint/misbehaviour_test.go @@ -1,4 +1,4 @@ -package types_test +package tendermint_test import ( "time" @@ -9,7 +9,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + tendermint "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibctestingmock "github.com/cosmos/ibc-go/v3/testing/mock" ) @@ -17,7 +17,7 @@ import ( func (suite *TendermintTestSuite) TestMisbehaviour() { heightMinus1 := clienttypes.NewHeight(0, height.RevisionHeight-1) - misbehaviour := &types.Misbehaviour{ + misbehaviour := &tendermint.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), heightMinus1, suite.now, suite.valSet, suite.valSet, suite.valSet, suite.signers), ClientId: clientID, @@ -47,130 +47,130 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { testCases := []struct { name string - misbehaviour *types.Misbehaviour - malleateMisbehaviour func(misbehaviour *types.Misbehaviour) error + misbehaviour *tendermint.Misbehaviour + malleateMisbehaviour func(misbehaviour *tendermint.Misbehaviour) error expPass bool }{ { "valid fork misbehaviour, two headers at same height have different time", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), heightMinus1, suite.now.Add(time.Minute), suite.valSet, suite.valSet, suite.valSet, suite.signers), ClientId: clientID, }, - func(misbehaviour *types.Misbehaviour) error { return nil }, + func(misbehaviour *tendermint.Misbehaviour) error { return nil }, true, }, { "valid time misbehaviour, both headers at different heights are at same time", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight+5), heightMinus1, suite.now, suite.valSet, suite.valSet, suite.valSet, suite.signers), Header2: suite.header, ClientId: clientID, }, - func(misbehaviour *types.Misbehaviour) error { return nil }, + func(misbehaviour *tendermint.Misbehaviour) error { return nil }, true, }, { "misbehaviour Header1 is nil", - types.NewMisbehaviour(clientID, nil, suite.header), - func(m *types.Misbehaviour) error { return nil }, + tendermint.NewMisbehaviour(clientID, nil, suite.header), + func(m *tendermint.Misbehaviour) error { return nil }, false, }, { "misbehaviour Header2 is nil", - types.NewMisbehaviour(clientID, suite.header, nil), - func(m *types.Misbehaviour) error { return nil }, + tendermint.NewMisbehaviour(clientID, suite.header, nil), + func(m *tendermint.Misbehaviour) error { return nil }, false, }, { "valid misbehaviour with different trusted headers", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), clienttypes.NewHeight(0, height.RevisionHeight-3), suite.now.Add(time.Minute), suite.valSet, suite.valSet, bothValSet, suite.signers), ClientId: clientID, }, - func(misbehaviour *types.Misbehaviour) error { return nil }, + func(misbehaviour *tendermint.Misbehaviour) error { return nil }, true, }, { "trusted height is 0 in Header1", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), clienttypes.ZeroHeight(), suite.now.Add(time.Minute), suite.valSet, suite.valSet, suite.valSet, suite.signers), Header2: suite.header, ClientId: clientID, }, - func(misbehaviour *types.Misbehaviour) error { return nil }, + func(misbehaviour *tendermint.Misbehaviour) error { return nil }, false, }, { "trusted height is 0 in Header2", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), clienttypes.ZeroHeight(), suite.now.Add(time.Minute), suite.valSet, suite.valSet, suite.valSet, suite.signers), ClientId: clientID, }, - func(misbehaviour *types.Misbehaviour) error { return nil }, + func(misbehaviour *tendermint.Misbehaviour) error { return nil }, false, }, { "trusted valset is nil in Header1", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), heightMinus1, suite.now.Add(time.Minute), suite.valSet, suite.valSet, nil, suite.signers), Header2: suite.header, ClientId: clientID, }, - func(misbehaviour *types.Misbehaviour) error { return nil }, + func(misbehaviour *tendermint.Misbehaviour) error { return nil }, false, }, { "trusted valset is nil in Header2", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), heightMinus1, suite.now.Add(time.Minute), suite.valSet, suite.valSet, nil, suite.signers), ClientId: clientID, }, - func(misbehaviour *types.Misbehaviour) error { return nil }, + func(misbehaviour *tendermint.Misbehaviour) error { return nil }, false, }, { "invalid client ID ", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), heightMinus1, suite.now, suite.valSet, suite.valSet, suite.valSet, suite.signers), ClientId: "GAIA", }, - func(misbehaviour *types.Misbehaviour) error { return nil }, + func(misbehaviour *tendermint.Misbehaviour) error { return nil }, false, }, { "chainIDs do not match", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader("ethermint", int64(height.RevisionHeight), heightMinus1, suite.now, suite.valSet, suite.valSet, suite.valSet, suite.signers), ClientId: clientID, }, - func(misbehaviour *types.Misbehaviour) error { return nil }, + func(misbehaviour *tendermint.Misbehaviour) error { return nil }, false, }, { "header2 height is greater", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, 6, clienttypes.NewHeight(0, height.RevisionHeight+1), suite.now, suite.valSet, suite.valSet, suite.valSet, suite.signers), ClientId: clientID, }, - func(misbehaviour *types.Misbehaviour) error { return nil }, + func(misbehaviour *tendermint.Misbehaviour) error { return nil }, false, }, { "header 1 doesn't have 2/3 majority", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), heightMinus1, suite.now, bothValSet, bothValSet, suite.valSet, bothSigners), Header2: suite.header, ClientId: clientID, }, - func(misbehaviour *types.Misbehaviour) error { + func(misbehaviour *tendermint.Misbehaviour) error { // voteSet contains only altVal which is less than 2/3 of total power (height/1height) wrongVoteSet := tmtypes.NewVoteSet(chainID, int64(misbehaviour.Header1.GetHeight().GetRevisionHeight()), 1, tmproto.PrecommitType, altValSet) blockID, err := tmtypes.BlockIDFromProto(&misbehaviour.Header1.Commit.BlockID) @@ -186,12 +186,12 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { }, { "header 2 doesn't have 2/3 majority", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), heightMinus1, suite.now, bothValSet, bothValSet, suite.valSet, bothSigners), ClientId: clientID, }, - func(misbehaviour *types.Misbehaviour) error { + func(misbehaviour *tendermint.Misbehaviour) error { // voteSet contains only altVal which is less than 2/3 of total power (height/1height) wrongVoteSet := tmtypes.NewVoteSet(chainID, int64(misbehaviour.Header2.GetHeight().GetRevisionHeight()), 1, tmproto.PrecommitType, altValSet) blockID, err := tmtypes.BlockIDFromProto(&misbehaviour.Header2.Commit.BlockID) @@ -207,12 +207,12 @@ func (suite *TendermintTestSuite) TestMisbehaviourValidateBasic() { }, { "validators sign off on wrong commit", - &types.Misbehaviour{ + &tendermint.Misbehaviour{ Header1: suite.header, Header2: suite.chainA.CreateTMClientHeader(chainID, int64(height.RevisionHeight), heightMinus1, suite.now, bothValSet, bothValSet, suite.valSet, bothSigners), ClientId: clientID, }, - func(misbehaviour *types.Misbehaviour) error { + func(misbehaviour *tendermint.Misbehaviour) error { tmBlockID := ibctesting.MakeBlockID(tmhash.Sum([]byte("other_hash")), 3, tmhash.Sum([]byte("other_partset"))) misbehaviour.Header2.Commit.BlockID = tmBlockID.ToProto() return nil diff --git a/modules/light-clients/07-tendermint/module.go b/modules/light-clients/07-tendermint/module.go index 429105b4d33..935bf34cafd 100644 --- a/modules/light-clients/07-tendermint/module.go +++ b/modules/light-clients/07-tendermint/module.go @@ -1,10 +1,6 @@ package tendermint -import ( - "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" -) - // Name returns the IBC client name func Name() string { - return types.SubModuleName + return SubModuleName } diff --git a/modules/light-clients/07-tendermint/types/proposal_handle.go b/modules/light-clients/07-tendermint/proposal_handle.go similarity index 97% rename from modules/light-clients/07-tendermint/types/proposal_handle.go rename to modules/light-clients/07-tendermint/proposal_handle.go index a938d181f65..62457e67876 100644 --- a/modules/light-clients/07-tendermint/types/proposal_handle.go +++ b/modules/light-clients/07-tendermint/proposal_handle.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( "reflect" @@ -15,14 +15,14 @@ import ( // substitute. // // AllowUpdateAfterMisbehaviour and AllowUpdateAfterExpiry have been deprecated. -// Please see ADR 026 for more information. -// +// Please see ADR 026 for more information. +// // The following must always be true: // - The substitute client is the same type as the subject client // - The subject and substitute client states match in all parameters (expect frozen height, latest height, and chain-id) // // In case 1) before updating the client, the client will be unfrozen by resetting -// the FrozenHeight to the zero Height. +// the FrozenHeight to the zero Height. func (cs ClientState) CheckSubstituteAndUpdateState( ctx sdk.Context, cdc codec.BinaryCodec, subjectClientStore, substituteClientStore sdk.KVStore, substituteClient exported.ClientState, diff --git a/modules/light-clients/07-tendermint/types/proposal_handle_test.go b/modules/light-clients/07-tendermint/proposal_handle_test.go similarity index 86% rename from modules/light-clients/07-tendermint/types/proposal_handle_test.go rename to modules/light-clients/07-tendermint/proposal_handle_test.go index 8d7ca6c7330..a14e80bae7b 100644 --- a/modules/light-clients/07-tendermint/types/proposal_handle_test.go +++ b/modules/light-clients/07-tendermint/proposal_handle_test.go @@ -1,4 +1,4 @@ -package types_test +package tendermint_test import ( "time" @@ -6,7 +6,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + tendermint "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) @@ -31,8 +31,8 @@ func (suite *TendermintTestSuite) TestCheckSubstituteUpdateStateBasic() { { "non-matching substitute", func() { suite.coordinator.SetupClients(substitutePath) - substituteClientState = suite.chainA.GetClientState(substitutePath.EndpointA.ClientID).(*types.ClientState) - tmClientState, ok := substituteClientState.(*types.ClientState) + substituteClientState = suite.chainA.GetClientState(substitutePath.EndpointA.ClientID).(*tendermint.ClientState) + tmClientState, ok := substituteClientState.(*tendermint.ClientState) suite.Require().True(ok) tmClientState.ChainId = tmClientState.ChainId + "different chain" @@ -50,7 +50,7 @@ func (suite *TendermintTestSuite) TestCheckSubstituteUpdateStateBasic() { substitutePath = ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(subjectPath) - subjectClientState := suite.chainA.GetClientState(subjectPath.EndpointA.ClientID).(*types.ClientState) + subjectClientState := suite.chainA.GetClientState(subjectPath.EndpointA.ClientID).(*tendermint.ClientState) subjectClientState.AllowUpdateAfterMisbehaviour = true subjectClientState.AllowUpdateAfterExpiry = true @@ -137,7 +137,7 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() { // construct subject using test case parameters subjectPath := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(subjectPath) - subjectClientState := suite.chainA.GetClientState(subjectPath.EndpointA.ClientID).(*types.ClientState) + subjectClientState := suite.chainA.GetClientState(subjectPath.EndpointA.ClientID).(*tendermint.ClientState) subjectClientState.AllowUpdateAfterExpiry = tc.AllowUpdateAfterExpiry subjectClientState.AllowUpdateAfterMisbehaviour = tc.AllowUpdateAfterMisbehaviour @@ -159,7 +159,7 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() { substitutePath := ibctesting.NewPath(suite.chainA, suite.chainB) suite.coordinator.SetupClients(substitutePath) - substituteClientState := suite.chainA.GetClientState(substitutePath.EndpointA.ClientID).(*types.ClientState) + substituteClientState := suite.chainA.GetClientState(substitutePath.EndpointA.ClientID).(*tendermint.ClientState) substituteClientState.AllowUpdateAfterExpiry = tc.AllowUpdateAfterExpiry substituteClientState.AllowUpdateAfterMisbehaviour = tc.AllowUpdateAfterMisbehaviour suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), substitutePath.EndpointA.ClientID, substituteClientState) @@ -173,7 +173,7 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() { } // get updated substitute - substituteClientState = suite.chainA.GetClientState(substitutePath.EndpointA.ClientID).(*types.ClientState) + substituteClientState = suite.chainA.GetClientState(substitutePath.EndpointA.ClientID).(*tendermint.ClientState) // test that subject gets updated chain-id newChainID := "new-chain-id" @@ -183,35 +183,35 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() { substituteClientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), substitutePath.EndpointA.ClientID) expectedConsState := substitutePath.EndpointA.GetConsensusState(substituteClientState.GetLatestHeight()) - expectedProcessedTime, found := types.GetProcessedTime(substituteClientStore, substituteClientState.GetLatestHeight()) + expectedProcessedTime, found := tendermint.GetProcessedTime(substituteClientStore, substituteClientState.GetLatestHeight()) suite.Require().True(found) - expectedProcessedHeight, found := types.GetProcessedTime(substituteClientStore, substituteClientState.GetLatestHeight()) + expectedProcessedHeight, found := tendermint.GetProcessedTime(substituteClientStore, substituteClientState.GetLatestHeight()) suite.Require().True(found) - expectedIterationKey := types.GetIterationKey(substituteClientStore, substituteClientState.GetLatestHeight()) + expectedIterationKey := tendermint.GetIterationKey(substituteClientStore, substituteClientState.GetLatestHeight()) updatedClient, err := subjectClientState.CheckSubstituteAndUpdateState(suite.chainA.GetContext(), suite.chainA.App.AppCodec(), subjectClientStore, substituteClientStore, substituteClientState) if tc.expPass { suite.Require().NoError(err) - suite.Require().Equal(clienttypes.ZeroHeight(), updatedClient.(*types.ClientState).FrozenHeight) + suite.Require().Equal(clienttypes.ZeroHeight(), updatedClient.(*tendermint.ClientState).FrozenHeight) subjectClientStore := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), subjectPath.EndpointA.ClientID) // check that the correct consensus state was copied over suite.Require().Equal(substituteClientState.GetLatestHeight(), updatedClient.GetLatestHeight()) subjectConsState := subjectPath.EndpointA.GetConsensusState(updatedClient.GetLatestHeight()) - subjectProcessedTime, found := types.GetProcessedTime(subjectClientStore, updatedClient.GetLatestHeight()) + subjectProcessedTime, found := tendermint.GetProcessedTime(subjectClientStore, updatedClient.GetLatestHeight()) suite.Require().True(found) - subjectProcessedHeight, found := types.GetProcessedTime(substituteClientStore, updatedClient.GetLatestHeight()) + subjectProcessedHeight, found := tendermint.GetProcessedTime(substituteClientStore, updatedClient.GetLatestHeight()) suite.Require().True(found) - subjectIterationKey := types.GetIterationKey(substituteClientStore, updatedClient.GetLatestHeight()) + subjectIterationKey := tendermint.GetIterationKey(substituteClientStore, updatedClient.GetLatestHeight()) suite.Require().Equal(expectedConsState, subjectConsState) suite.Require().Equal(expectedProcessedTime, subjectProcessedTime) suite.Require().Equal(expectedProcessedHeight, subjectProcessedHeight) suite.Require().Equal(expectedIterationKey, subjectIterationKey) - suite.Require().Equal(newChainID, updatedClient.(*types.ClientState).ChainId) + suite.Require().Equal(newChainID, updatedClient.(*tendermint.ClientState).ChainId) // ensure updated client state is set in store bz := subjectClientStore.Get(host.ClientStateKey()) @@ -228,7 +228,7 @@ func (suite *TendermintTestSuite) TestCheckSubstituteAndUpdateState() { func (suite *TendermintTestSuite) TestIsMatchingClientState() { var ( subjectPath, substitutePath *ibctesting.Path - subjectClientState, substituteClientState *types.ClientState + subjectClientState, substituteClientState *tendermint.ClientState ) testCases := []struct { @@ -238,8 +238,8 @@ func (suite *TendermintTestSuite) TestIsMatchingClientState() { }{ { "matching clients", func() { - subjectClientState = suite.chainA.GetClientState(subjectPath.EndpointA.ClientID).(*types.ClientState) - substituteClientState = suite.chainA.GetClientState(substitutePath.EndpointA.ClientID).(*types.ClientState) + subjectClientState = suite.chainA.GetClientState(subjectPath.EndpointA.ClientID).(*tendermint.ClientState) + substituteClientState = suite.chainA.GetClientState(substitutePath.EndpointA.ClientID).(*tendermint.ClientState) }, true, }, { @@ -281,7 +281,7 @@ func (suite *TendermintTestSuite) TestIsMatchingClientState() { tc.malleate() - suite.Require().Equal(tc.expPass, types.IsMatchingClientState(*subjectClientState, *substituteClientState)) + suite.Require().Equal(tc.expPass, tendermint.IsMatchingClientState(*subjectClientState, *substituteClientState)) }) } diff --git a/modules/light-clients/07-tendermint/types/store.go b/modules/light-clients/07-tendermint/store.go similarity index 99% rename from modules/light-clients/07-tendermint/types/store.go rename to modules/light-clients/07-tendermint/store.go index fabd29f3161..2be5e94c97e 100644 --- a/modules/light-clients/07-tendermint/types/store.go +++ b/modules/light-clients/07-tendermint/store.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( "bytes" diff --git a/modules/light-clients/07-tendermint/types/store_test.go b/modules/light-clients/07-tendermint/store_test.go similarity index 64% rename from modules/light-clients/07-tendermint/types/store_test.go rename to modules/light-clients/07-tendermint/store_test.go index 28877a49386..f5d57ded2cd 100644 --- a/modules/light-clients/07-tendermint/types/store_test.go +++ b/modules/light-clients/07-tendermint/store_test.go @@ -1,4 +1,4 @@ -package types_test +package tendermint_test import ( "math" @@ -8,8 +8,8 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" - "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + solomachine "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" + tendermint "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) @@ -38,7 +38,7 @@ func (suite *TendermintTestSuite) TestGetConsensusState() { "not a consensus state interface", func() { // marshal an empty client state and set as consensus state store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID) - clientStateBz := suite.chainA.App.GetIBCKeeper().ClientKeeper.MustMarshalClientState(&types.ClientState{}) + clientStateBz := suite.chainA.App.GetIBCKeeper().ClientKeeper.MustMarshalClientState(&tendermint.ClientState{}) store.Set(host.ConsensusStateKey(height), clientStateBz) }, false, true, }, @@ -46,7 +46,7 @@ func (suite *TendermintTestSuite) TestGetConsensusState() { "invalid consensus state (solomachine)", func() { // marshal and set solomachine consensus state store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID) - consensusStateBz := suite.chainA.App.GetIBCKeeper().ClientKeeper.MustMarshalConsensusState(&solomachinetypes.ConsensusState{}) + consensusStateBz := suite.chainA.App.GetIBCKeeper().ClientKeeper.MustMarshalConsensusState(&solomachine.ConsensusState{}) store.Set(host.ConsensusStateKey(height), consensusStateBz) }, false, true, }, @@ -68,14 +68,14 @@ func (suite *TendermintTestSuite) TestGetConsensusState() { if tc.expPanic { suite.Require().Panics(func() { store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID) - types.GetConsensusState(store, suite.chainA.Codec, height) + tendermint.GetConsensusState(store, suite.chainA.Codec, height) }) return } store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID) - consensusState, found := types.GetConsensusState(store, suite.chainA.Codec, height) + consensusState, found := tendermint.GetConsensusState(store, suite.chainA.Codec, height) if tc.expPass { suite.Require().True(found) @@ -107,7 +107,7 @@ func (suite *TendermintTestSuite) TestGetProcessedTime() { height := clientState.GetLatestHeight() store := suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID) - actualTime, ok := types.GetProcessedTime(store, height) + actualTime, ok := tendermint.GetProcessedTime(store, height) suite.Require().True(ok, "could not retrieve processed time for stored consensus state") suite.Require().Equal(uint64(expectedTime.UnixNano()), actualTime, "retrieved processed time is not expected value") @@ -123,12 +123,12 @@ func (suite *TendermintTestSuite) TestGetProcessedTime() { height = clientState.GetLatestHeight() store = suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), path.EndpointA.ClientID) - actualTime, ok = types.GetProcessedTime(store, height) + actualTime, ok = tendermint.GetProcessedTime(store, height) suite.Require().True(ok, "could not retrieve processed time for stored consensus state") suite.Require().Equal(uint64(expectedTime.UnixNano()), actualTime, "retrieved processed time is not expected value") // try to get processed time for height that doesn't exist in store - _, ok = types.GetProcessedTime(store, clienttypes.NewHeight(1, 1)) + _, ok = tendermint.GetProcessedTime(store, clienttypes.NewHeight(1, 1)) suite.Require().False(ok, "retrieved processed time for a non-existent consensus state") } @@ -140,8 +140,8 @@ func (suite *TendermintTestSuite) TestIterationKey() { clienttypes.NewHeight(math.MaxUint64, math.MaxUint64), } for _, h := range testHeights { - k := types.IterationKey(h) - retrievedHeight := types.GetHeightFromIterationKey(k) + k := tendermint.IterationKey(h) + retrievedHeight := tendermint.GetHeightFromIterationKey(k) suite.Require().Equal(h, retrievedHeight, "retrieving height from iteration key failed") } } @@ -150,16 +150,16 @@ func (suite *TendermintTestSuite) TestIterateConsensusStates() { nextValsHash := []byte("nextVals") // Set iteration keys and consensus states - types.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), clienttypes.NewHeight(0, 1)) - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", clienttypes.NewHeight(0, 1), types.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("hash0-1")), nextValsHash)) - types.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), clienttypes.NewHeight(4, 9)) - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", clienttypes.NewHeight(4, 9), types.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("hash4-9")), nextValsHash)) - types.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), clienttypes.NewHeight(0, 10)) - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", clienttypes.NewHeight(0, 10), types.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("hash0-10")), nextValsHash)) - types.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), clienttypes.NewHeight(0, 4)) - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", clienttypes.NewHeight(0, 4), types.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("hash0-4")), nextValsHash)) - types.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), clienttypes.NewHeight(40, 1)) - suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", clienttypes.NewHeight(40, 1), types.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("hash40-1")), nextValsHash)) + tendermint.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), clienttypes.NewHeight(0, 1)) + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", clienttypes.NewHeight(0, 1), tendermint.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("hash0-1")), nextValsHash)) + tendermint.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), clienttypes.NewHeight(4, 9)) + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", clienttypes.NewHeight(4, 9), tendermint.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("hash4-9")), nextValsHash)) + tendermint.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), clienttypes.NewHeight(0, 10)) + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", clienttypes.NewHeight(0, 10), tendermint.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("hash0-10")), nextValsHash)) + tendermint.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), clienttypes.NewHeight(0, 4)) + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", clienttypes.NewHeight(0, 4), tendermint.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("hash0-4")), nextValsHash)) + tendermint.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), clienttypes.NewHeight(40, 1)) + suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", clienttypes.NewHeight(40, 1), tendermint.NewConsensusState(time.Now(), commitmenttypes.NewMerkleRoot([]byte("hash40-1")), nextValsHash)) var testArr []string cb := func(height exported.Height) bool { @@ -167,39 +167,39 @@ func (suite *TendermintTestSuite) TestIterateConsensusStates() { return false } - types.IterateConsensusStateAscending(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), cb) + tendermint.IterateConsensusStateAscending(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), cb) expectedArr := []string{"0-1", "0-4", "0-10", "4-9", "40-1"} suite.Require().Equal(expectedArr, testArr) } func (suite *TendermintTestSuite) TestGetNeighboringConsensusStates() { nextValsHash := []byte("nextVals") - cs01 := types.NewConsensusState(time.Now().UTC(), commitmenttypes.NewMerkleRoot([]byte("hash0-1")), nextValsHash) - cs04 := types.NewConsensusState(time.Now().UTC(), commitmenttypes.NewMerkleRoot([]byte("hash0-4")), nextValsHash) - cs49 := types.NewConsensusState(time.Now().UTC(), commitmenttypes.NewMerkleRoot([]byte("hash4-9")), nextValsHash) + cs01 := tendermint.NewConsensusState(time.Now().UTC(), commitmenttypes.NewMerkleRoot([]byte("hash0-1")), nextValsHash) + cs04 := tendermint.NewConsensusState(time.Now().UTC(), commitmenttypes.NewMerkleRoot([]byte("hash0-4")), nextValsHash) + cs49 := tendermint.NewConsensusState(time.Now().UTC(), commitmenttypes.NewMerkleRoot([]byte("hash4-9")), nextValsHash) height01 := clienttypes.NewHeight(0, 1) height04 := clienttypes.NewHeight(0, 4) height49 := clienttypes.NewHeight(4, 9) // Set iteration keys and consensus states - types.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), height01) + tendermint.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), height01) suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", height01, cs01) - types.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), height04) + tendermint.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), height04) suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", height04, cs04) - types.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), height49) + tendermint.SetIterationKey(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), height49) suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), "testClient", height49, cs49) - prevCs01, ok := types.GetPreviousConsensusState(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), suite.chainA.Codec, height01) + prevCs01, ok := tendermint.GetPreviousConsensusState(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), suite.chainA.Codec, height01) suite.Require().Nil(prevCs01, "consensus state exists before lowest consensus state") suite.Require().False(ok) - prevCs49, ok := types.GetPreviousConsensusState(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), suite.chainA.Codec, height49) + prevCs49, ok := tendermint.GetPreviousConsensusState(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), suite.chainA.Codec, height49) suite.Require().Equal(cs04, prevCs49, "previous consensus state is not returned correctly") suite.Require().True(ok) - nextCs01, ok := types.GetNextConsensusState(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), suite.chainA.Codec, height01) + nextCs01, ok := tendermint.GetNextConsensusState(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), suite.chainA.Codec, height01) suite.Require().Equal(cs04, nextCs01, "next consensus state not returned correctly") suite.Require().True(ok) - nextCs49, ok := types.GetNextConsensusState(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), suite.chainA.Codec, height49) + nextCs49, ok := tendermint.GetNextConsensusState(suite.chainA.App.GetIBCKeeper().ClientKeeper.ClientStore(suite.chainA.GetContext(), "testClient"), suite.chainA.Codec, height49) suite.Require().Nil(nextCs49, "next consensus state exists after highest consensus state") suite.Require().False(ok) } diff --git a/modules/light-clients/07-tendermint/types/tendermint.pb.go b/modules/light-clients/07-tendermint/tendermint.pb.go similarity index 87% rename from modules/light-clients/07-tendermint/types/tendermint.pb.go rename to modules/light-clients/07-tendermint/tendermint.pb.go index 00d2cba20e1..7bac5c42672 100644 --- a/modules/light-clients/07-tendermint/types/tendermint.pb.go +++ b/modules/light-clients/07-tendermint/tendermint.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. // source: ibc/lightclients/tendermint/v1/tendermint.proto -package types +package tendermint import ( fmt "fmt" @@ -323,75 +323,75 @@ func init() { } var fileDescriptor_c6d6cf2b288949be = []byte{ - // 1078 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcf, 0x6f, 0xe3, 0x44, - 0x14, 0x6e, 0xda, 0xb2, 0x4d, 0x26, 0xe9, 0x76, 0x31, 0xa5, 0x9b, 0x96, 0x6e, 0x1c, 0x19, 0xa9, - 0xe4, 0x40, 0x6d, 0x92, 0x22, 0x21, 0x55, 0x5c, 0x70, 0x77, 0x51, 0x8b, 0x58, 0xa9, 0x72, 0xf9, - 0x21, 0x21, 0x21, 0x33, 0xb1, 0x27, 0xc9, 0x68, 0x6d, 0x8f, 0xe5, 0x99, 0x84, 0x96, 0xbf, 0x00, - 0x4e, 0xec, 0x11, 0x71, 0xe2, 0xc0, 0x1f, 0xb3, 0xc7, 0x1e, 0x39, 0x19, 0xd4, 0x5e, 0x39, 0xe5, - 0xc8, 0x09, 0xcd, 0x0f, 0xdb, 0xd3, 0x6c, 0x97, 0x6a, 0xb9, 0x44, 0xf3, 0xde, 0xfb, 0xde, 0xf7, - 0x65, 0xe6, 0xbd, 0x79, 0x63, 0xe0, 0xe0, 0x61, 0xe0, 0x44, 0x78, 0x3c, 0x61, 0x41, 0x84, 0x51, - 0xc2, 0xa8, 0xc3, 0x50, 0x12, 0xa2, 0x2c, 0xc6, 0x09, 0x73, 0x66, 0x7d, 0xcd, 0xb2, 0xd3, 0x8c, - 0x30, 0x62, 0x74, 0xf0, 0x30, 0xb0, 0xf5, 0x04, 0x5b, 0x83, 0xcc, 0xfa, 0x3b, 0x5d, 0x2d, 0x9f, - 0x5d, 0xa4, 0x88, 0x3a, 0x33, 0x18, 0xe1, 0x10, 0x32, 0x92, 0x49, 0x86, 0x9d, 0xdd, 0x97, 0x10, - 0xe2, 0x57, 0x45, 0x5b, 0x69, 0x46, 0xc8, 0xa8, 0xb0, 0x3a, 0x63, 0x42, 0xc6, 0x11, 0x72, 0x84, - 0x35, 0x9c, 0x8e, 0x9c, 0x70, 0x9a, 0x41, 0x86, 0x49, 0xa2, 0xe2, 0xe6, 0x62, 0x9c, 0xe1, 0x18, - 0x51, 0x06, 0xe3, 0xb4, 0x00, 0xf0, 0xfd, 0x05, 0x24, 0x43, 0x8e, 0xfc, 0xbb, 0x7c, 0x4f, 0x72, - 0xa5, 0x00, 0xef, 0x55, 0x00, 0x12, 0xc7, 0x98, 0xc5, 0x05, 0xa8, 0xb4, 0x14, 0x70, 0x73, 0x4c, - 0xc6, 0x44, 0x2c, 0x1d, 0xbe, 0x92, 0x5e, 0xeb, 0xef, 0x35, 0xd0, 0x3c, 0x12, 0x7c, 0x67, 0x0c, - 0x32, 0x64, 0x6c, 0x83, 0x7a, 0x30, 0x81, 0x38, 0xf1, 0x71, 0xd8, 0xae, 0x75, 0x6b, 0xbd, 0x86, - 0xb7, 0x26, 0xec, 0x93, 0xd0, 0x40, 0xa0, 0xc9, 0xb2, 0x29, 0x65, 0x7e, 0x84, 0x66, 0x28, 0x6a, - 0x2f, 0x77, 0x6b, 0xbd, 0xe6, 0xa0, 0x67, 0xff, 0xf7, 0x79, 0xda, 0x9f, 0x66, 0x30, 0xe0, 0x1b, - 0x76, 0x77, 0x5e, 0xe4, 0xe6, 0xd2, 0x3c, 0x37, 0x8d, 0x0b, 0x18, 0x47, 0x87, 0x96, 0x46, 0x65, - 0x79, 0x40, 0x58, 0x9f, 0x73, 0xc3, 0x18, 0x81, 0x0d, 0x61, 0xe1, 0x64, 0xec, 0xa7, 0x28, 0xc3, - 0x24, 0x6c, 0xaf, 0x08, 0xa9, 0x6d, 0x5b, 0x1e, 0x96, 0x5d, 0x1c, 0x96, 0xfd, 0x58, 0x1d, 0xa6, - 0x6b, 0x29, 0xee, 0x2d, 0x8d, 0xbb, 0xca, 0xb7, 0x7e, 0xf9, 0xd3, 0xac, 0x79, 0xf7, 0x0b, 0xef, - 0xa9, 0x70, 0x1a, 0x18, 0x3c, 0x98, 0x26, 0x43, 0x92, 0x84, 0x9a, 0xd0, 0xea, 0x5d, 0x42, 0xef, - 0x2a, 0xa1, 0x87, 0x52, 0x68, 0x91, 0x40, 0x2a, 0x6d, 0x94, 0x6e, 0x25, 0x85, 0xc0, 0x46, 0x0c, - 0xcf, 0xfd, 0x20, 0x22, 0xc1, 0x33, 0x3f, 0xcc, 0xf0, 0x88, 0xb5, 0xdf, 0x78, 0xcd, 0x2d, 0x2d, - 0xe4, 0x4b, 0xa1, 0xf5, 0x18, 0x9e, 0x1f, 0x71, 0xe7, 0x63, 0xee, 0x33, 0xbe, 0x05, 0xeb, 0xa3, - 0x8c, 0xfc, 0x80, 0x12, 0x7f, 0x82, 0x78, 0x41, 0xda, 0xf7, 0x84, 0xc8, 0x8e, 0x28, 0x11, 0x6f, - 0x11, 0x5b, 0x75, 0xce, 0xac, 0x6f, 0x1f, 0x0b, 0x84, 0xbb, 0xab, 0x54, 0x36, 0xa5, 0xca, 0x8d, - 0x74, 0xcb, 0x6b, 0x49, 0x5b, 0x62, 0x39, 0x7d, 0x04, 0x19, 0xa2, 0xac, 0xa0, 0x5f, 0x7b, 0x5d, - 0xfa, 0x1b, 0xe9, 0x96, 0xd7, 0x92, 0xb6, 0xa2, 0x3f, 0x01, 0x4d, 0x71, 0x75, 0x7c, 0x9a, 0xa2, - 0x80, 0xb6, 0xeb, 0xdd, 0x95, 0x5e, 0x73, 0xf0, 0xc0, 0xc6, 0x01, 0x1d, 0x1c, 0xd8, 0xa7, 0x3c, - 0x72, 0x96, 0xa2, 0xc0, 0xdd, 0xaa, 0x5a, 0x48, 0x83, 0x5b, 0x1e, 0x48, 0x0b, 0x08, 0x35, 0x0e, - 0x41, 0x6b, 0x9a, 0x8e, 0x33, 0x18, 0x22, 0x3f, 0x85, 0x6c, 0xd2, 0x6e, 0x74, 0x57, 0x7a, 0x0d, - 0xf7, 0xe1, 0x3c, 0x37, 0xdf, 0x52, 0x75, 0xd3, 0xa2, 0x96, 0xd7, 0x54, 0xe6, 0x29, 0x64, 0x13, - 0x03, 0x82, 0x6d, 0x18, 0x45, 0xe4, 0x7b, 0x7f, 0x9a, 0x86, 0x90, 0x21, 0x1f, 0x8e, 0x18, 0xca, - 0x7c, 0x74, 0x9e, 0xe2, 0xec, 0xa2, 0x0d, 0xba, 0xb5, 0x5e, 0xdd, 0xdd, 0x9b, 0xe7, 0x66, 0x57, - 0x12, 0xbd, 0x12, 0x6a, 0xb5, 0x6b, 0xde, 0x96, 0x88, 0x7e, 0x29, 0x82, 0x9f, 0xf0, 0xd8, 0x13, - 0x11, 0x32, 0x28, 0x30, 0x6f, 0xc9, 0x8b, 0x31, 0x1d, 0xa2, 0x09, 0x9c, 0x61, 0x32, 0xcd, 0xda, - 0x4d, 0x21, 0xf4, 0xfe, 0x3c, 0x37, 0xf7, 0x5e, 0x29, 0xa4, 0x27, 0x70, 0xb9, 0xdd, 0x45, 0xb9, - 0xa7, 0x1a, 0xe0, 0x70, 0xf5, 0xc7, 0xdf, 0xcc, 0x25, 0xeb, 0xf7, 0x65, 0x70, 0xff, 0x88, 0x24, - 0x14, 0x25, 0x74, 0x4a, 0xe5, 0x8d, 0x77, 0x41, 0xa3, 0x1c, 0x3a, 0xe2, 0xca, 0xf3, 0x92, 0x2e, - 0xb6, 0xe5, 0x17, 0x05, 0xc2, 0xad, 0xf3, 0x92, 0x3e, 0xe7, 0xdd, 0x57, 0xa5, 0x19, 0x1f, 0x83, - 0xd5, 0x8c, 0x10, 0xa6, 0x66, 0x82, 0xa5, 0x75, 0x44, 0x35, 0x85, 0x66, 0x7d, 0xfb, 0x29, 0xca, - 0x9e, 0x45, 0xc8, 0x23, 0x84, 0xb9, 0xab, 0x9c, 0xc6, 0x13, 0x59, 0xc6, 0x4f, 0x35, 0xb0, 0x99, - 0xa0, 0x73, 0xe6, 0x97, 0x93, 0x96, 0xfa, 0x13, 0x48, 0x27, 0xe2, 0xde, 0xb7, 0xdc, 0xaf, 0xe7, - 0xb9, 0xf9, 0x8e, 0x3c, 0x85, 0xdb, 0x50, 0xd6, 0x3f, 0xb9, 0xf9, 0xe1, 0x18, 0xb3, 0xc9, 0x74, - 0xc8, 0xe5, 0xf4, 0xf9, 0xaf, 0x2d, 0x23, 0x3c, 0xa4, 0xce, 0xf0, 0x82, 0x21, 0x6a, 0x1f, 0xa3, - 0x73, 0x97, 0x2f, 0x3c, 0x83, 0xd3, 0x7d, 0x55, 0xb2, 0x1d, 0x43, 0x3a, 0x51, 0xc7, 0xf4, 0xf3, - 0x32, 0x68, 0xe9, 0xa7, 0x67, 0x1c, 0x80, 0x86, 0x6c, 0xee, 0x72, 0x2e, 0x8a, 0x46, 0x7c, 0x20, - 0xff, 0x56, 0x19, 0xe2, 0x65, 0xa8, 0x4b, 0xeb, 0x24, 0x34, 0x20, 0xa8, 0x4f, 0x10, 0x0c, 0x51, - 0xe6, 0xf7, 0xd5, 0xc9, 0xec, 0xdd, 0x35, 0x2d, 0x8f, 0x05, 0xde, 0xed, 0x5c, 0xe5, 0xe6, 0x9a, - 0x5c, 0xf7, 0xe7, 0xb9, 0xb9, 0x21, 0x65, 0x0a, 0x32, 0xcb, 0x5b, 0x93, 0xcb, 0xbe, 0x26, 0x31, - 0x50, 0x53, 0xf2, 0x7f, 0x48, 0x0c, 0x5e, 0x92, 0x18, 0x94, 0x12, 0x03, 0x75, 0x22, 0xbf, 0xae, - 0x80, 0x7b, 0x12, 0x6d, 0x40, 0xb0, 0x4e, 0xf1, 0x38, 0x41, 0xa1, 0x2f, 0x21, 0xaa, 0x69, 0x3a, - 0xba, 0x8e, 0x7c, 0x11, 0xcf, 0x04, 0x4c, 0x09, 0xee, 0x5e, 0xe6, 0x66, 0xad, 0x9a, 0x05, 0x37, - 0x28, 0x2c, 0xaf, 0x45, 0x35, 0x2c, 0x1f, 0x35, 0x65, 0x95, 0x7d, 0x8a, 0x8a, 0xc6, 0xba, 0x45, - 0xa2, 0x2c, 0xdf, 0x19, 0x62, 0x6e, 0xbb, 0xa2, 0xbf, 0x91, 0x6e, 0x79, 0xad, 0x99, 0x86, 0x33, - 0xbe, 0x03, 0xf2, 0x31, 0x10, 0xfa, 0x62, 0x94, 0xad, 0xdc, 0x39, 0xca, 0x1e, 0xa9, 0x51, 0xf6, - 0xb6, 0xf6, 0xc4, 0x94, 0xf9, 0x96, 0xb7, 0xae, 0x1c, 0x6a, 0x98, 0x45, 0xc0, 0x28, 0x10, 0x55, - 0xbb, 0xaa, 0xe7, 0xe5, 0xae, 0x5d, 0x3c, 0x9a, 0xe7, 0xe6, 0xf6, 0x4d, 0x95, 0x8a, 0xc3, 0xf2, - 0xde, 0x54, 0xce, 0xaa, 0x71, 0xad, 0xcf, 0x40, 0xbd, 0x78, 0x66, 0x8d, 0x5d, 0xd0, 0x48, 0xa6, - 0x31, 0xca, 0x78, 0x44, 0x54, 0x66, 0xd5, 0xab, 0x1c, 0x46, 0x17, 0x34, 0x43, 0x94, 0x90, 0x18, - 0x27, 0x22, 0xbe, 0x2c, 0xe2, 0xba, 0xcb, 0xf5, 0x5f, 0x5c, 0x75, 0x6a, 0x97, 0x57, 0x9d, 0xda, - 0x5f, 0x57, 0x9d, 0xda, 0xf3, 0xeb, 0xce, 0xd2, 0xe5, 0x75, 0x67, 0xe9, 0x8f, 0xeb, 0xce, 0xd2, - 0x37, 0x4f, 0xb4, 0x4b, 0x16, 0x10, 0x1a, 0x13, 0xca, 0x3f, 0xbe, 0xf6, 0xc7, 0xc4, 0x99, 0x1d, - 0x38, 0x31, 0x09, 0xa7, 0x11, 0xa2, 0xf2, 0x53, 0x6c, 0xbf, 0xf8, 0x16, 0xfb, 0xe0, 0xa3, 0xfd, - 0xc5, 0x8f, 0xa5, 0xe1, 0x3d, 0x31, 0x54, 0x0e, 0xfe, 0x0d, 0x00, 0x00, 0xff, 0xff, 0xdd, 0xc8, - 0x3e, 0xfe, 0xba, 0x09, 0x00, 0x00, + // 1082 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcf, 0x6f, 0xe3, 0xc4, + 0x17, 0x6f, 0xda, 0x7e, 0xdb, 0x64, 0x92, 0x6e, 0xfb, 0x35, 0xa5, 0x9b, 0x96, 0x6e, 0x1c, 0x19, + 0xa9, 0xe4, 0x40, 0x6d, 0x92, 0x22, 0x21, 0x15, 0x2e, 0xb8, 0x0b, 0x6a, 0x57, 0xac, 0x54, 0xb9, + 0xfc, 0x90, 0x90, 0x90, 0x99, 0xd8, 0x93, 0x64, 0xb4, 0xb6, 0xc7, 0xf2, 0x4c, 0x42, 0xcb, 0x5f, + 0x00, 0x27, 0xf6, 0x88, 0x38, 0x71, 0xe0, 0x8f, 0xd9, 0x63, 0x8f, 0x9c, 0x0c, 0x6a, 0xaf, 0x9c, + 0x72, 0xe4, 0x84, 0xe6, 0x87, 0xed, 0x69, 0xb7, 0x4b, 0xb5, 0x5c, 0xa2, 0x79, 0xef, 0x7d, 0xde, + 0xe7, 0x93, 0x99, 0xf7, 0xe6, 0x8d, 0x81, 0x83, 0x87, 0x81, 0x13, 0xe1, 0xf1, 0x84, 0x05, 0x11, + 0x46, 0x09, 0xa3, 0x0e, 0x43, 0x49, 0x88, 0xb2, 0x18, 0x27, 0xcc, 0x99, 0xf5, 0x35, 0xcb, 0x4e, + 0x33, 0xc2, 0x88, 0xd1, 0xc1, 0xc3, 0xc0, 0xd6, 0x13, 0x6c, 0x0d, 0x32, 0xeb, 0xef, 0x74, 0xb5, + 0x7c, 0x76, 0x91, 0x22, 0xea, 0xcc, 0x60, 0x84, 0x43, 0xc8, 0x48, 0x26, 0x19, 0x76, 0x76, 0x5f, + 0x42, 0x88, 0x5f, 0x15, 0x6d, 0xa5, 0x19, 0x21, 0xa3, 0xc2, 0xea, 0x8c, 0x09, 0x19, 0x47, 0xc8, + 0x11, 0xd6, 0x70, 0x3a, 0x72, 0xc2, 0x69, 0x06, 0x19, 0x26, 0x89, 0x8a, 0x9b, 0xb7, 0xe3, 0x0c, + 0xc7, 0x88, 0x32, 0x18, 0xa7, 0x05, 0x80, 0xef, 0x2f, 0x20, 0x19, 0x72, 0xe4, 0xdf, 0xe5, 0x7b, + 0x92, 0x2b, 0x05, 0x78, 0xa7, 0x02, 0x90, 0x38, 0xc6, 0x2c, 0x2e, 0x40, 0xa5, 0xa5, 0x80, 0x9b, + 0x63, 0x32, 0x26, 0x62, 0xe9, 0xf0, 0x95, 0xf4, 0x5a, 0x7f, 0xad, 0x82, 0xe6, 0x91, 0xe0, 0x3b, + 0x63, 0x90, 0x21, 0x63, 0x1b, 0xd4, 0x83, 0x09, 0xc4, 0x89, 0x8f, 0xc3, 0x76, 0xad, 0x5b, 0xeb, + 0x35, 0xbc, 0x55, 0x61, 0x9f, 0x84, 0x06, 0x02, 0x4d, 0x96, 0x4d, 0x29, 0xf3, 0x23, 0x34, 0x43, + 0x51, 0x7b, 0xb1, 0x5b, 0xeb, 0x35, 0x07, 0x3d, 0xfb, 0xdf, 0xcf, 0xd3, 0xfe, 0x34, 0x83, 0x01, + 0xdf, 0xb0, 0xbb, 0xf3, 0x22, 0x37, 0x17, 0xe6, 0xb9, 0x69, 0x5c, 0xc0, 0x38, 0x3a, 0xb4, 0x34, + 0x2a, 0xcb, 0x03, 0xc2, 0xfa, 0x8c, 0x1b, 0xc6, 0x08, 0xac, 0x0b, 0x0b, 0x27, 0x63, 0x3f, 0x45, + 0x19, 0x26, 0x61, 0x7b, 0x49, 0x48, 0x6d, 0xdb, 0xf2, 0xb0, 0xec, 0xe2, 0xb0, 0xec, 0xc7, 0xea, + 0x30, 0x5d, 0x4b, 0x71, 0x6f, 0x69, 0xdc, 0x55, 0xbe, 0xf5, 0xf3, 0x1f, 0x66, 0xcd, 0x7b, 0x50, + 0x78, 0x4f, 0x85, 0xd3, 0xc0, 0x60, 0x63, 0x9a, 0x0c, 0x49, 0x12, 0x6a, 0x42, 0xcb, 0xf7, 0x09, + 0xbd, 0xad, 0x84, 0x1e, 0x4a, 0xa1, 0xdb, 0x04, 0x52, 0x69, 0xbd, 0x74, 0x2b, 0x29, 0x04, 0xd6, + 0x63, 0x78, 0xee, 0x07, 0x11, 0x09, 0x9e, 0xf9, 0x61, 0x86, 0x47, 0xac, 0xfd, 0xbf, 0xd7, 0xdc, + 0xd2, 0xad, 0x7c, 0x29, 0xb4, 0x16, 0xc3, 0xf3, 0x23, 0xee, 0x7c, 0xcc, 0x7d, 0xc6, 0x37, 0x60, + 0x6d, 0x94, 0x91, 0xef, 0x51, 0xe2, 0x4f, 0x10, 0x2f, 0x48, 0x7b, 0x45, 0x88, 0xec, 0x88, 0x12, + 0xf1, 0x16, 0xb1, 0x55, 0xe7, 0xcc, 0xfa, 0xf6, 0xb1, 0x40, 0xb8, 0xbb, 0x4a, 0x65, 0x53, 0xaa, + 0xdc, 0x48, 0xb7, 0xbc, 0x96, 0xb4, 0x25, 0x96, 0xd3, 0x47, 0x90, 0x21, 0xca, 0x0a, 0xfa, 0xd5, + 0xd7, 0xa5, 0xbf, 0x91, 0x6e, 0x79, 0x2d, 0x69, 0x2b, 0xfa, 0x13, 0xd0, 0x14, 0x57, 0xc7, 0xa7, + 0x29, 0x0a, 0x68, 0xbb, 0xde, 0x5d, 0xea, 0x35, 0x07, 0x1b, 0x36, 0x0e, 0xe8, 0xe0, 0xc0, 0x3e, + 0xe5, 0x91, 0xb3, 0x14, 0x05, 0xee, 0x56, 0xd5, 0x42, 0x1a, 0xdc, 0xf2, 0x40, 0x5a, 0x40, 0xa8, + 0x71, 0x08, 0x5a, 0xd3, 0x74, 0x9c, 0xc1, 0x10, 0xf9, 0x29, 0x64, 0x93, 0x76, 0xa3, 0xbb, 0xd4, + 0x6b, 0xb8, 0x0f, 0xe7, 0xb9, 0xf9, 0x86, 0xaa, 0x9b, 0x16, 0xb5, 0xbc, 0xa6, 0x32, 0x4f, 0x21, + 0x9b, 0x18, 0x10, 0x6c, 0xc3, 0x28, 0x22, 0xdf, 0xf9, 0xd3, 0x34, 0x84, 0x0c, 0xf9, 0x70, 0xc4, + 0x50, 0xe6, 0xa3, 0xf3, 0x14, 0x67, 0x17, 0x6d, 0xd0, 0xad, 0xf5, 0xea, 0xee, 0xde, 0x3c, 0x37, + 0xbb, 0x92, 0xe8, 0x95, 0x50, 0xab, 0x5d, 0xf3, 0xb6, 0x44, 0xf4, 0x0b, 0x11, 0xfc, 0x98, 0xc7, + 0x3e, 0x11, 0x21, 0x83, 0x02, 0xf3, 0x8e, 0xbc, 0x18, 0xd3, 0x21, 0x9a, 0xc0, 0x19, 0x26, 0xd3, + 0xac, 0xdd, 0x14, 0x42, 0xef, 0xce, 0x73, 0x73, 0xef, 0x95, 0x42, 0x7a, 0x02, 0x97, 0xdb, 0xbd, + 0x2d, 0xf7, 0x54, 0x03, 0x1c, 0x2e, 0xff, 0xf0, 0xab, 0xb9, 0x60, 0xfd, 0xb6, 0x08, 0x1e, 0x1c, + 0x91, 0x84, 0xa2, 0x84, 0x4e, 0xa9, 0xbc, 0xf1, 0x2e, 0x68, 0x94, 0x43, 0x47, 0x5c, 0x79, 0x5e, + 0xd2, 0xdb, 0x6d, 0xf9, 0x79, 0x81, 0x70, 0xeb, 0xbc, 0xa4, 0xcf, 0x79, 0xf7, 0x55, 0x69, 0xc6, + 0x47, 0x60, 0x39, 0x23, 0x84, 0xa9, 0x99, 0x60, 0x69, 0x1d, 0x51, 0x4d, 0xa1, 0x59, 0xdf, 0x7e, + 0x8a, 0xb2, 0x67, 0x11, 0xf2, 0x08, 0x61, 0xee, 0x32, 0xa7, 0xf1, 0x44, 0x96, 0xf1, 0x63, 0x0d, + 0x6c, 0x26, 0xe8, 0x9c, 0xf9, 0xe5, 0xa4, 0xa5, 0xfe, 0x04, 0xd2, 0x89, 0xb8, 0xf7, 0x2d, 0xf7, + 0xab, 0x79, 0x6e, 0xbe, 0x25, 0x4f, 0xe1, 0x2e, 0x94, 0xf5, 0x77, 0x6e, 0xbe, 0x3f, 0xc6, 0x6c, + 0x32, 0x1d, 0x72, 0x39, 0x7d, 0xfe, 0x6b, 0xcb, 0x08, 0x0f, 0xa9, 0x33, 0xbc, 0x60, 0x88, 0xda, + 0xc7, 0xe8, 0xdc, 0xe5, 0x0b, 0xcf, 0xe0, 0x74, 0x5f, 0x96, 0x6c, 0xc7, 0x90, 0x4e, 0xd4, 0x31, + 0xfd, 0xb4, 0x08, 0x5a, 0xfa, 0xe9, 0x19, 0x07, 0xa0, 0x21, 0x9b, 0xbb, 0x9c, 0x8b, 0xa2, 0x11, + 0x37, 0xe4, 0xdf, 0x2a, 0x43, 0xbc, 0x0c, 0x75, 0x69, 0x9d, 0x84, 0x06, 0x04, 0xf5, 0x09, 0x82, + 0x21, 0xca, 0xfc, 0xbe, 0x3a, 0x99, 0xbd, 0xfb, 0xa6, 0xe5, 0xb1, 0xc0, 0xbb, 0x9d, 0xab, 0xdc, + 0x5c, 0x95, 0xeb, 0xfe, 0x3c, 0x37, 0xd7, 0xa5, 0x4c, 0x41, 0x66, 0x79, 0xab, 0x72, 0xd9, 0xd7, + 0x24, 0x06, 0x6a, 0x4a, 0xfe, 0x07, 0x89, 0xc1, 0x4b, 0x12, 0x83, 0x52, 0x62, 0xa0, 0x4e, 0xe4, + 0x97, 0x25, 0xb0, 0x22, 0xd1, 0x06, 0x04, 0x6b, 0x14, 0x8f, 0x13, 0x14, 0xfa, 0x12, 0xa2, 0x9a, + 0xa6, 0xa3, 0xeb, 0xc8, 0x17, 0xf1, 0x4c, 0xc0, 0x94, 0xe0, 0xee, 0x65, 0x6e, 0xd6, 0xaa, 0x59, + 0x70, 0x83, 0xc2, 0xf2, 0x5a, 0x54, 0xc3, 0xf2, 0x51, 0x53, 0x56, 0xd9, 0xa7, 0xa8, 0x68, 0xac, + 0x3b, 0x24, 0xca, 0xf2, 0x9d, 0x21, 0xe6, 0xb6, 0x2b, 0xfa, 0x1b, 0xe9, 0x96, 0xd7, 0x9a, 0x69, + 0x38, 0xe3, 0x5b, 0x20, 0x1f, 0x03, 0xa1, 0x2f, 0x46, 0xd9, 0xd2, 0xbd, 0xa3, 0xec, 0x91, 0x1a, + 0x65, 0x6f, 0x6a, 0x4f, 0x4c, 0x99, 0x6f, 0x79, 0x6b, 0xca, 0xa1, 0x86, 0x59, 0x04, 0x8c, 0x02, + 0x51, 0xb5, 0xab, 0x7a, 0x5e, 0xee, 0xdb, 0xc5, 0xa3, 0x79, 0x6e, 0x6e, 0xdf, 0x54, 0xa9, 0x38, + 0x2c, 0xef, 0xff, 0xca, 0x59, 0x35, 0xae, 0xf5, 0x04, 0xd4, 0x8b, 0x67, 0xd6, 0xd8, 0x05, 0x8d, + 0x64, 0x1a, 0xa3, 0x8c, 0x47, 0x44, 0x65, 0x96, 0xbd, 0xca, 0x61, 0x74, 0x41, 0x33, 0x44, 0x09, + 0x89, 0x71, 0x22, 0xe2, 0x8b, 0x22, 0xae, 0xbb, 0xdc, 0xf0, 0xc5, 0x55, 0xa7, 0x76, 0x79, 0xd5, + 0xa9, 0xfd, 0x79, 0xd5, 0xa9, 0x3d, 0xbf, 0xee, 0x2c, 0x5c, 0x5e, 0x77, 0x16, 0x7e, 0xbf, 0xee, + 0x2c, 0x7c, 0xfd, 0x44, 0xbb, 0x64, 0x01, 0xa1, 0x31, 0xa1, 0xfc, 0xe3, 0x6b, 0x7f, 0x4c, 0x9c, + 0xd9, 0x81, 0x13, 0x93, 0x70, 0x1a, 0x21, 0x2a, 0x3f, 0xc5, 0xf6, 0x8b, 0x6f, 0xb1, 0xf7, 0x3e, + 0xd8, 0xaf, 0xf6, 0xfa, 0x61, 0xb5, 0x1c, 0xae, 0x88, 0xc9, 0x72, 0xf0, 0x4f, 0x00, 0x00, 0x00, + 0xff, 0xff, 0x3e, 0x30, 0x59, 0x01, 0xbf, 0x09, 0x00, 0x00, } func (m *ClientState) Marshal() (dAtA []byte, err error) { diff --git a/modules/light-clients/07-tendermint/types/tendermint_test.go b/modules/light-clients/07-tendermint/tendermint_test.go similarity index 96% rename from modules/light-clients/07-tendermint/types/tendermint_test.go rename to modules/light-clients/07-tendermint/tendermint_test.go index 898a48efe72..843e1f71c57 100644 --- a/modules/light-clients/07-tendermint/types/tendermint_test.go +++ b/modules/light-clients/07-tendermint/tendermint_test.go @@ -1,4 +1,4 @@ -package types_test +package tendermint_test import ( "testing" @@ -12,7 +12,7 @@ import ( tmtypes "github.com/tendermint/tendermint/types" clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + tendermint "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibctestingmock "github.com/cosmos/ibc-go/v3/testing/mock" "github.com/cosmos/ibc-go/v3/testing/simapp" @@ -50,7 +50,7 @@ type TendermintTestSuite struct { valSet *tmtypes.ValidatorSet signers map[string]tmtypes.PrivValidator valsHash tmbytes.HexBytes - header *ibctmtypes.Header + header *tendermint.Header now time.Time headerTime time.Time clientTime time.Time diff --git a/modules/light-clients/07-tendermint/types/update.go b/modules/light-clients/07-tendermint/update.go similarity index 99% rename from modules/light-clients/07-tendermint/types/update.go rename to modules/light-clients/07-tendermint/update.go index 31d16799118..f1606748b07 100644 --- a/modules/light-clients/07-tendermint/types/update.go +++ b/modules/light-clients/07-tendermint/update.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( "bytes" diff --git a/modules/light-clients/07-tendermint/types/update_test.go b/modules/light-clients/07-tendermint/update_test.go similarity index 93% rename from modules/light-clients/07-tendermint/types/update_test.go rename to modules/light-clients/07-tendermint/update_test.go index abe9cfb9382..dec1e384a86 100644 --- a/modules/light-clients/07-tendermint/types/update_test.go +++ b/modules/light-clients/07-tendermint/update_test.go @@ -1,4 +1,4 @@ -package types_test +package tendermint_test import ( "time" @@ -8,8 +8,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" - types "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + tendermint "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ibctestingmock "github.com/cosmos/ibc-go/v3/testing/mock" tmtypes "github.com/tendermint/tendermint/types" @@ -18,7 +17,7 @@ import ( func (suite *TendermintTestSuite) TestVerifyHeader() { var ( path *ibctesting.Path - header *ibctmtypes.Header + header *tendermint.Header ) // Setup different validators and signers for testing different types of updates @@ -322,12 +321,12 @@ func (suite *TendermintTestSuite) TestUpdateState() { }{ { "success with height later than latest height", func() { - tmHeader, ok := clientMessage.(*types.Header) + tmHeader, ok := clientMessage.(*tendermint.Header) suite.Require().True(ok) suite.Require().True(path.EndpointA.GetClientState().GetLatestHeight().LT(tmHeader.GetHeight())) }, func() { - tmHeader, ok := clientMessage.(*types.Header) + tmHeader, ok := clientMessage.(*tendermint.Header) suite.Require().True(ok) clientState := path.EndpointA.GetClientState() @@ -343,7 +342,7 @@ func (suite *TendermintTestSuite) TestUpdateState() { err := path.EndpointA.UpdateClient() suite.Require().NoError(err) - tmHeader, ok := clientMessage.(*types.Header) + tmHeader, ok := clientMessage.(*tendermint.Header) suite.Require().True(ok) suite.Require().True(path.EndpointA.GetClientState().GetLatestHeight().GT(tmHeader.GetHeight())) @@ -365,7 +364,7 @@ func (suite *TendermintTestSuite) TestUpdateState() { clientMessage, err = path.EndpointA.Chain.ConstructUpdateTMClientHeader(path.EndpointA.Counterparty.Chain, path.EndpointA.ClientID) suite.Require().NoError(err) - tmHeader, ok := clientMessage.(*types.Header) + tmHeader, ok := clientMessage.(*tendermint.Header) suite.Require().True(ok) suite.Require().Equal(path.EndpointA.GetClientState().GetLatestHeight(), tmHeader.GetHeight()) @@ -377,7 +376,7 @@ func (suite *TendermintTestSuite) TestUpdateState() { suite.Require().Equal(clientState, prevClientState) suite.Require().True(clientState.GetLatestHeight().EQ(consensusHeights[0])) - tmHeader, ok := clientMessage.(*types.Header) + tmHeader, ok := clientMessage.(*tendermint.Header) suite.Require().True(ok) suite.Require().Equal(path.EndpointA.GetConsensusState(tmHeader.GetHeight()), prevConsensusState) }, true, @@ -408,7 +407,7 @@ func (suite *TendermintTestSuite) TestUpdateState() { suite.Require().NoError(err) }, func() { - tmHeader, ok := clientMessage.(*types.Header) + tmHeader, ok := clientMessage.(*tendermint.Header) suite.Require().True(ok) clientState := path.EndpointA.GetClientState() @@ -422,7 +421,7 @@ func (suite *TendermintTestSuite) TestUpdateState() { }, { "invalid ClientMessage type", func() { - clientMessage = &types.Misbehaviour{} + clientMessage = &tendermint.Misbehaviour{} }, func() {}, false, @@ -451,8 +450,8 @@ func (suite *TendermintTestSuite) TestUpdateState() { if tc.expPass { consensusHeights = clientState.UpdateState(suite.chainA.GetContext(), suite.chainA.App.AppCodec(), clientStore, clientMessage) - header := clientMessage.(*types.Header) - expConsensusState := &types.ConsensusState{ + header := clientMessage.(*tendermint.Header) + expConsensusState := &tendermint.ConsensusState{ Timestamp: header.GetTime(), Root: commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), NextValidatorsHash: header.Header.NextValidatorsHash, @@ -488,7 +487,7 @@ func (suite *TendermintTestSuite) TestPruneConsensusState() { } ctx := path.EndpointA.Chain.GetContext() clientStore := path.EndpointA.Chain.App.GetIBCKeeper().ClientKeeper.ClientStore(ctx, path.EndpointA.ClientID) - err := types.IterateConsensusStateAscending(clientStore, getFirstHeightCb) + err := tendermint.IterateConsensusStateAscending(clientStore, getFirstHeightCb) suite.Require().Nil(err) // this height will be expired but not pruned @@ -500,11 +499,11 @@ func (suite *TendermintTestSuite) TestPruneConsensusState() { suite.Require().True(ok) ctx = path.EndpointA.Chain.GetContext() clientStore = path.EndpointA.Chain.App.GetIBCKeeper().ClientKeeper.ClientStore(ctx, path.EndpointA.ClientID) - expectedProcessTime, ok := types.GetProcessedTime(clientStore, expiredHeight) + expectedProcessTime, ok := tendermint.GetProcessedTime(clientStore, expiredHeight) suite.Require().True(ok) - expectedProcessHeight, ok := types.GetProcessedHeight(clientStore, expiredHeight) + expectedProcessHeight, ok := tendermint.GetProcessedHeight(clientStore, expiredHeight) suite.Require().True(ok) - expectedConsKey := types.GetIterationKey(clientStore, expiredHeight) + expectedConsKey := tendermint.GetIterationKey(clientStore, expiredHeight) suite.Require().NotNil(expectedConsKey) // Increment the time by a week @@ -526,15 +525,15 @@ func (suite *TendermintTestSuite) TestPruneConsensusState() { suite.Require().Nil(consState, "expired consensus state not pruned") suite.Require().False(ok) // check processed time metadata is pruned - processTime, ok := types.GetProcessedTime(clientStore, pruneHeight) + processTime, ok := tendermint.GetProcessedTime(clientStore, pruneHeight) suite.Require().Equal(uint64(0), processTime, "processed time metadata not pruned") suite.Require().False(ok) - processHeight, ok := types.GetProcessedHeight(clientStore, pruneHeight) + processHeight, ok := tendermint.GetProcessedHeight(clientStore, pruneHeight) suite.Require().Nil(processHeight, "processed height metadata not pruned") suite.Require().False(ok) // check iteration key metadata is pruned - consKey := types.GetIterationKey(clientStore, pruneHeight) + consKey := tendermint.GetIterationKey(clientStore, pruneHeight) suite.Require().Nil(consKey, "iteration key not pruned") // check that second expired consensus state doesn't get deleted @@ -543,17 +542,17 @@ func (suite *TendermintTestSuite) TestPruneConsensusState() { suite.Require().Equal(expectedConsState, consState, "consensus state incorrectly pruned") suite.Require().True(ok) // check processed time metadata is not pruned - processTime, ok = types.GetProcessedTime(clientStore, expiredHeight) + processTime, ok = tendermint.GetProcessedTime(clientStore, expiredHeight) suite.Require().Equal(expectedProcessTime, processTime, "processed time metadata incorrectly pruned") suite.Require().True(ok) // check processed height metadata is not pruned - processHeight, ok = types.GetProcessedHeight(clientStore, expiredHeight) + processHeight, ok = tendermint.GetProcessedHeight(clientStore, expiredHeight) suite.Require().Equal(expectedProcessHeight, processHeight, "processed height metadata incorrectly pruned") suite.Require().True(ok) // check iteration key metadata is not pruned - consKey = types.GetIterationKey(clientStore, expiredHeight) + consKey = tendermint.GetIterationKey(clientStore, expiredHeight) suite.Require().Equal(expectedConsKey, consKey, "iteration key incorrectly pruned") } @@ -576,16 +575,16 @@ func (suite *TendermintTestSuite) TestCheckForMisbehaviour() { { "consensus state already exists, already updated", func() { - header, ok := clientMessage.(*types.Header) + header, ok := clientMessage.(*tendermint.Header) suite.Require().True(ok) - consensusState := &types.ConsensusState{ + consensusState := &tendermint.ConsensusState{ Timestamp: header.GetTime(), Root: commitmenttypes.NewMerkleRoot(header.Header.GetAppHash()), NextValidatorsHash: header.Header.NextValidatorsHash, } - tmHeader, ok := clientMessage.(*types.Header) + tmHeader, ok := clientMessage.(*tendermint.Header) suite.Require().True(ok) suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), path.EndpointA.ClientID, tmHeader.GetHeight(), consensusState) }, @@ -594,16 +593,16 @@ func (suite *TendermintTestSuite) TestCheckForMisbehaviour() { { "consensus state already exists, app hash mismatch", func() { - header, ok := clientMessage.(*types.Header) + header, ok := clientMessage.(*tendermint.Header) suite.Require().True(ok) - consensusState := &types.ConsensusState{ + consensusState := &tendermint.ConsensusState{ Timestamp: header.GetTime(), Root: commitmenttypes.NewMerkleRoot([]byte{}), // empty bytes NextValidatorsHash: header.Header.NextValidatorsHash, } - tmHeader, ok := clientMessage.(*types.Header) + tmHeader, ok := clientMessage.(*tendermint.Header) suite.Require().True(ok) suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientConsensusState(suite.chainA.GetContext(), path.EndpointA.ClientID, tmHeader.GetHeight(), consensusState) }, @@ -612,7 +611,7 @@ func (suite *TendermintTestSuite) TestCheckForMisbehaviour() { { "previous consensus state exists and header time is before previous consensus state time", func() { - header, ok := clientMessage.(*types.Header) + header, ok := clientMessage.(*tendermint.Header) suite.Require().True(ok) // offset header timestamp before previous consensus state timestamp @@ -623,7 +622,7 @@ func (suite *TendermintTestSuite) TestCheckForMisbehaviour() { { "next consensus state exists and header time is after next consensus state time", func() { - header, ok := clientMessage.(*types.Header) + header, ok := clientMessage.(*tendermint.Header) suite.Require().True(ok) // commit block and update client, adding a new consensus state @@ -653,7 +652,7 @@ func (suite *TendermintTestSuite) TestCheckForMisbehaviour() { // assign the same height, each header will have a different commit hash header1.Header.Height = header2.Header.Height - clientMessage = &types.Misbehaviour{ + clientMessage = &tendermint.Misbehaviour{ Header1: header1, Header2: header2, ClientId: path.EndpointA.ClientID, @@ -739,7 +738,7 @@ func (suite *TendermintTestSuite) TestUpdateStateOnMisbehaviour() { suite.Require().NotEmpty(clientStateBz) newClientState := clienttypes.MustUnmarshalClientState(suite.chainA.Codec, clientStateBz) - suite.Require().Equal(frozenHeight, newClientState.(*types.ClientState).FrozenHeight) + suite.Require().Equal(frozenHeight, newClientState.(*tendermint.ClientState).FrozenHeight) } }) } diff --git a/modules/light-clients/07-tendermint/types/upgrade.go b/modules/light-clients/07-tendermint/upgrade.go similarity index 99% rename from modules/light-clients/07-tendermint/types/upgrade.go rename to modules/light-clients/07-tendermint/upgrade.go index e295f8e4ba3..9d3e25ae5fa 100644 --- a/modules/light-clients/07-tendermint/types/upgrade.go +++ b/modules/light-clients/07-tendermint/upgrade.go @@ -1,4 +1,4 @@ -package types +package tendermint import ( "fmt" diff --git a/modules/light-clients/07-tendermint/types/upgrade_test.go b/modules/light-clients/07-tendermint/upgrade_test.go similarity index 93% rename from modules/light-clients/07-tendermint/types/upgrade_test.go rename to modules/light-clients/07-tendermint/upgrade_test.go index 218991fc4e9..601ab53d046 100644 --- a/modules/light-clients/07-tendermint/types/upgrade_test.go +++ b/modules/light-clients/07-tendermint/upgrade_test.go @@ -1,4 +1,4 @@ -package types_test +package tendermint_test import ( upgradetypes "github.com/cosmos/cosmos-sdk/x/upgrade/types" @@ -6,7 +6,7 @@ import ( clienttypes "github.com/cosmos/ibc-go/v3/modules/core/02-client/types" commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + tendermint "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ibctesting "github.com/cosmos/ibc-go/v3/testing" ) @@ -54,7 +54,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { { name: "successful upgrade to same revision", setup: func() { - upgradedClient = types.NewClientState(suite.chainB.ChainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, clienttypes.NewHeight(clienttypes.ParseChainID(suite.chainB.ChainID), upgradedClient.GetLatestHeight().GetRevisionHeight()+10), commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = tendermint.NewClientState(suite.chainB.ChainID, tendermint.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, clienttypes.NewHeight(clienttypes.ParseChainID(suite.chainB.ChainID), upgradedClient.GetLatestHeight().GetRevisionHeight()+10), commitmenttypes.GetSDKSpecs(), upgradePath, false, false) upgradedClient = upgradedClient.ZeroCustomFields() upgradedClientBz, err = clienttypes.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient) suite.Require().NoError(err) @@ -109,7 +109,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "unsuccessful upgrade: committed client does not have zeroed custom fields", setup: func() { // non-zeroed upgrade client - upgradedClient = types.NewClientState(newChainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = tendermint.NewClientState(newChainID, tendermint.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) upgradedClientBz, err = clienttypes.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient) suite.Require().NoError(err) @@ -145,7 +145,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) // change upgradedClient client-specified parameters - upgradedClient = types.NewClientState("wrongchainID", types.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, true) + upgradedClient = tendermint.NewClientState("wrongchainID", tendermint.DefaultTrustLevel, trustingPeriod, ubdPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, true) suite.coordinator.CommitBlock(suite.chainB) err := path.EndpointA.UpdateClient() @@ -167,7 +167,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) // change upgradedClient client-specified parameters - upgradedClient = types.NewClientState(newChainID, types.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, lastHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, false) + upgradedClient = tendermint.NewClientState(newChainID, tendermint.DefaultTrustLevel, ubdPeriod, ubdPeriod+trustingPeriod, maxClockDrift+5, lastHeight, commitmenttypes.GetSDKSpecs(), upgradePath, true, false) suite.coordinator.CommitBlock(suite.chainB) err := path.EndpointA.UpdateClient() @@ -192,7 +192,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { suite.chainB.GetSimApp().UpgradeKeeper.SetUpgradedConsensusState(suite.chainB.GetContext(), int64(lastHeight.GetRevisionHeight()), upgradedConsStateBz) // change submitted upgradedConsensusState - upgradedConsState = &types.ConsensusState{ + upgradedConsState = &tendermint.ConsensusState{ NextValidatorsHash: []byte("maliciousValidators"), } @@ -296,7 +296,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { proofUpgradedConsState, _ = suite.chainB.QueryUpgradeProof(upgradetypes.UpgradedConsStateKey(int64(lastHeight.GetRevisionHeight())), cs.GetLatestHeight().GetRevisionHeight()) // SetClientState with empty upgrade path - tmClient, _ := cs.(*types.ClientState) + tmClient, _ := cs.(*tendermint.ClientState) tmClient.UpgradePath = []string{""} suite.chainA.App.GetIBCKeeper().ClientKeeper.SetClientState(suite.chainA.GetContext(), path.EndpointA.ClientID, tmClient) }, @@ -398,7 +398,7 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { name: "unsuccessful upgrade: final client is not valid", setup: func() { // new client has smaller unbonding period such that old trusting period is no longer valid - upgradedClient = types.NewClientState(newChainID, types.DefaultTrustLevel, trustingPeriod, trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = tendermint.NewClientState(newChainID, tendermint.DefaultTrustLevel, trustingPeriod, trustingPeriod, maxClockDrift, newClientHeight, commitmenttypes.GetSDKSpecs(), upgradePath, false, false) upgradedClientBz, err = clienttypes.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient) suite.Require().NoError(err) @@ -434,19 +434,19 @@ func (suite *TendermintTestSuite) TestVerifyUpgrade() { suite.coordinator.SetupClients(path) - clientState := path.EndpointA.GetClientState().(*types.ClientState) + clientState := path.EndpointA.GetClientState().(*tendermint.ClientState) revisionNumber := clienttypes.ParseChainID(clientState.ChainId) var err error newChainID, err = clienttypes.SetRevisionNumber(clientState.ChainId, revisionNumber+1) suite.Require().NoError(err) - upgradedClient = types.NewClientState(newChainID, types.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, clienttypes.NewHeight(revisionNumber+1, clientState.GetLatestHeight().GetRevisionHeight()+1), commitmenttypes.GetSDKSpecs(), upgradePath, false, false) + upgradedClient = tendermint.NewClientState(newChainID, tendermint.DefaultTrustLevel, trustingPeriod, ubdPeriod+trustingPeriod, maxClockDrift, clienttypes.NewHeight(revisionNumber+1, clientState.GetLatestHeight().GetRevisionHeight()+1), commitmenttypes.GetSDKSpecs(), upgradePath, false, false) upgradedClient = upgradedClient.ZeroCustomFields() upgradedClientBz, err = clienttypes.MarshalClientState(suite.chainA.App.AppCodec(), upgradedClient) suite.Require().NoError(err) - upgradedConsState = &types.ConsensusState{ + upgradedConsState = &tendermint.ConsensusState{ NextValidatorsHash: []byte("nextValsHash"), } upgradedConsStateBz, err = clienttypes.MarshalConsensusState(suite.chainA.App.AppCodec(), upgradedConsState) diff --git a/proto/ibc/lightclients/solomachine/v2/solomachine.proto b/proto/ibc/lightclients/solomachine/v2/solomachine.proto index f4f36910eb2..5f0de59c6d7 100644 --- a/proto/ibc/lightclients/solomachine/v2/solomachine.proto +++ b/proto/ibc/lightclients/solomachine/v2/solomachine.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package ibc.lightclients.solomachine.v2; -option go_package = "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types"; +option go_package = "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine;solomachine"; import "ibc/core/connection/v1/connection.proto"; import "ibc/core/channel/v1/channel.proto"; diff --git a/proto/ibc/lightclients/tendermint/v1/tendermint.proto b/proto/ibc/lightclients/tendermint/v1/tendermint.proto index 7221f6502fa..89ab3595684 100644 --- a/proto/ibc/lightclients/tendermint/v1/tendermint.proto +++ b/proto/ibc/lightclients/tendermint/v1/tendermint.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package ibc.lightclients.tendermint.v1; -option go_package = "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types"; +option go_package = "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint;tendermint"; import "tendermint/types/validator.proto"; import "tendermint/types/types.proto"; diff --git a/testing/chain.go b/testing/chain.go index 769acd8f7d1..9b6dbf40590 100644 --- a/testing/chain.go +++ b/testing/chain.go @@ -30,7 +30,7 @@ import ( host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" "github.com/cosmos/ibc-go/v3/modules/core/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" "github.com/cosmos/ibc-go/v3/testing/mock" "github.com/cosmos/ibc-go/v3/testing/simapp" ) diff --git a/testing/config.go b/testing/config.go index a47dea1701b..673e374b5ba 100644 --- a/testing/config.go +++ b/testing/config.go @@ -6,7 +6,7 @@ import ( connectiontypes "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types" channeltypes "github.com/cosmos/ibc-go/v3/modules/core/04-channel/types" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" "github.com/cosmos/ibc-go/v3/testing/mock" ) diff --git a/testing/endpoint.go b/testing/endpoint.go index 093f657e5b6..d332ae97a6e 100644 --- a/testing/endpoint.go +++ b/testing/endpoint.go @@ -13,7 +13,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" ) // Endpoint is a which represents a channel endpoint and its associated diff --git a/testing/solomachine.go b/testing/solomachine.go index 485fb75be0e..5eea01fbb19 100644 --- a/testing/solomachine.go +++ b/testing/solomachine.go @@ -16,7 +16,7 @@ import ( commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" host "github.com/cosmos/ibc-go/v3/modules/core/24-host" "github.com/cosmos/ibc-go/v3/modules/core/exported" - solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine/types" + solomachinetypes "github.com/cosmos/ibc-go/v3/modules/light-clients/06-solomachine" ) // Solomachine is a testing helper used to simulate a counterparty diff --git a/testing/values.go b/testing/values.go index 655a4731a74..3591711e24a 100644 --- a/testing/values.go +++ b/testing/values.go @@ -12,7 +12,7 @@ import ( ibctransfertypes "github.com/cosmos/ibc-go/v3/modules/apps/transfer/types" connectiontypes "github.com/cosmos/ibc-go/v3/modules/core/03-connection/types" commitmenttypes "github.com/cosmos/ibc-go/v3/modules/core/23-commitment/types" - ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint/types" + ibctmtypes "github.com/cosmos/ibc-go/v3/modules/light-clients/07-tendermint" "github.com/cosmos/ibc-go/v3/testing/mock" "github.com/cosmos/ibc-go/v3/testing/simapp" )