From c7ae820c35e6225752e20ec5fa6f199c88b59270 Mon Sep 17 00:00:00 2001 From: Ranadeep Biswas Date: Tue, 30 Apr 2024 22:35:22 +0200 Subject: [PATCH] use TestContext --- docs/architecture/adr-009-revamp-testkit.md | 35 ++++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/docs/architecture/adr-009-revamp-testkit.md b/docs/architecture/adr-009-revamp-testkit.md index 4cd6f5f283..740e84b17f 100644 --- a/docs/architecture/adr-009-revamp-testkit.md +++ b/docs/architecture/adr-009-revamp-testkit.md @@ -198,7 +198,7 @@ key. So the `MockContext` is finalized as: ```rs -pub struct MockGenericContext +pub struct MockContext where S: ProvableStore + Debug, H: TestHost @@ -306,15 +306,34 @@ and [`hosts/tendermint.rs`](https://github.com/cosmos/ibc-rs/blob/feat/refactor-testkit/ibc-testkit/src/hosts/tendermint.rs#L42) respectively. -#### MockGenericContext +#### Renaming `MockContext` to `StoreGenericTestContext` -[`MockGenericContext`](https://github.com/cosmos/ibc-rs/blob/feat/refactor-testkit/ibc-testkit/src/context.rs#L34-L52) -is actually what is described as `MockContext` in the ADR. For simplicity, we -defined `MockContext` to -[have a concrete store](https://github.com/cosmos/ibc-rs/blob/feat/refactor-testkit/ibc-testkit/src/context.rs#L54-L55) -implementation. +There was confusion about what is a _Test_ component and what is a _Mock_ +component. We have `MockContext` with `MockClient` and `TendermintClient`. + +To avoid this confusion, we renamed `MockContext` to `StoreGenericTestContext`. +This means that going forward all our general frameworks and traits should have +`Test` in their name. But a dummy concrete implementation of these traits may +have `Mock` in their name. + +#### StoreGenericTestContext + +[`StoreGenericTestContext`](https://github.com/cosmos/ibc-rs/blob/feat/refactor-testkit/ibc-testkit/src/context.rs#L34-L52) +is actually what is described as `MockContext` in the ADR. For convenience, we +defined `TestContext` to have a concrete store implementation - +[`MockStore`](https://github.com/cosmos/ibc-rs/blob/feat/refactor-testkit/ibc-testkit/src/context.rs#L55-L56). ```rs +// A mock store type using basecoin-storage implementations. pub type MockStore = RevertibleStore>; -pub type MockContext = MockGenericContext; + +pub type TestContext = StoreGenericTestContext; +``` + +With this, we can now define `MockContext` which uses `MockStore` and `MockHost` +and `TendermintContext` which uses `MockStore` and `TendermintHost`. + +``` +pub type MockContext = TestContext; +pub type TendermintContext = TestContext; ```