diff --git a/lib/tests/e2e/suite.go b/lib/tests/e2e/suite.go index 8a9a443..e4ef2b2 100644 --- a/lib/tests/e2e/suite.go +++ b/lib/tests/e2e/suite.go @@ -9,6 +9,7 @@ import ( clitestutil "github.com/planetmint/planetmint-go/testutil/cli" "github.com/planetmint/planetmint-go/testutil/network" "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/util" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" @@ -36,6 +37,7 @@ func (s *E2ETestSuite) SetupSuite() { // TearDownSuite clean up after testing func (s *E2ETestSuite) TearDownSuite() { + util.TerminationWaitGroup.Wait() s.T().Log("tearing down e2e test suite") } diff --git a/tests/e2e/asset/suite.go b/tests/e2e/asset/suite.go index 7688cad..b5ec3ac 100644 --- a/tests/e2e/asset/suite.go +++ b/tests/e2e/asset/suite.go @@ -4,6 +4,7 @@ import ( "github.com/planetmint/planetmint-go/lib" "github.com/planetmint/planetmint-go/testutil/network" "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/util" clitestutil "github.com/planetmint/planetmint-go/testutil/cli" e2etestutil "github.com/planetmint/planetmint-go/testutil/e2e" @@ -38,6 +39,7 @@ func (s *E2ETestSuite) SetupSuite() { // TearDownSuite clean up after testing func (s *E2ETestSuite) TearDownSuite() { + util.TerminationWaitGroup.Wait() s.T().Log("tearing down e2e test suite") } diff --git a/tests/e2e/dao/asset_distribution_suite.go b/tests/e2e/dao/asset_distribution_suite.go index 2c3d204..3f6a000 100644 --- a/tests/e2e/dao/asset_distribution_suite.go +++ b/tests/e2e/dao/asset_distribution_suite.go @@ -6,6 +6,7 @@ import ( clitestutil "github.com/planetmint/planetmint-go/testutil/cli" "github.com/planetmint/planetmint-go/testutil/network" + "github.com/planetmint/planetmint-go/util" daocli "github.com/planetmint/planetmint-go/x/dao/client/cli" daotypes "github.com/planetmint/planetmint-go/x/dao/types" "github.com/stretchr/testify/suite" @@ -41,6 +42,7 @@ func (s *AssetDistributionE2ETestSuite) SetupSuite() { } func (s *AssetDistributionE2ETestSuite) TearDownSuite() { + util.TerminationWaitGroup.Wait() s.T().Log("tearing down e2e test suites") } diff --git a/tests/e2e/dao/gas_consumption_suite.go b/tests/e2e/dao/gas_consumption_suite.go index 7a2a3cf..9daa34c 100644 --- a/tests/e2e/dao/gas_consumption_suite.go +++ b/tests/e2e/dao/gas_consumption_suite.go @@ -15,6 +15,7 @@ import ( "github.com/planetmint/planetmint-go/testutil/moduleobject" "github.com/planetmint/planetmint-go/testutil/network" "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/util" daotypes "github.com/planetmint/planetmint-go/x/dao/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" @@ -93,6 +94,7 @@ func (s *GasConsumptionE2ETestSuite) SetupSuite() { } func (s *GasConsumptionE2ETestSuite) TearDownSuite() { + util.TerminationWaitGroup.Wait() s.T().Log("tearing down e2e test suites") } diff --git a/tests/e2e/dao/pop_participant_selection_suite.go b/tests/e2e/dao/pop_participant_selection_suite.go index 33a06fb..70b250f 100644 --- a/tests/e2e/dao/pop_participant_selection_suite.go +++ b/tests/e2e/dao/pop_participant_selection_suite.go @@ -17,6 +17,7 @@ import ( e2etestutil "github.com/planetmint/planetmint-go/testutil/e2e" "github.com/planetmint/planetmint-go/testutil/network" "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/util" daocli "github.com/planetmint/planetmint-go/x/dao/client/cli" daotypes "github.com/planetmint/planetmint-go/x/dao/types" "github.com/stretchr/testify/assert" @@ -86,6 +87,7 @@ func (s *PopSelectionE2ETestSuite) SetupSuite() { // TearDownSuite clean up after testing func (s *PopSelectionE2ETestSuite) TearDownSuite() { + util.TerminationWaitGroup.Wait() s.T().Log("tearing down e2e test suite") } diff --git a/tests/e2e/dao/restricted_msgs_suite.go b/tests/e2e/dao/restricted_msgs_suite.go index e4cf52d..46e1cdc 100644 --- a/tests/e2e/dao/restricted_msgs_suite.go +++ b/tests/e2e/dao/restricted_msgs_suite.go @@ -6,6 +6,7 @@ import ( e2etestutil "github.com/planetmint/planetmint-go/testutil/e2e" "github.com/planetmint/planetmint-go/testutil/network" "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/util" daotypes "github.com/planetmint/planetmint-go/x/dao/types" machinetypes "github.com/planetmint/planetmint-go/x/machine/types" "github.com/stretchr/testify/suite" @@ -44,6 +45,7 @@ func (s *RestrictedMsgsE2ESuite) SetupSuite() { } func (s *RestrictedMsgsE2ESuite) TearDownSuite() { + util.TerminationWaitGroup.Wait() s.T().Log("tearing down e2e test suite") } diff --git a/tests/e2e/dao/suite.go b/tests/e2e/dao/suite.go index 1ec8e81..04d2db0 100644 --- a/tests/e2e/dao/suite.go +++ b/tests/e2e/dao/suite.go @@ -14,6 +14,7 @@ import ( e2etestutil "github.com/planetmint/planetmint-go/testutil/e2e" "github.com/planetmint/planetmint-go/testutil/network" "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/util" daocli "github.com/planetmint/planetmint-go/x/dao/client/cli" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/suite" @@ -109,6 +110,7 @@ func (s *E2ETestSuite) SetupSuite() { // TearDownSuite clean up after testing func (s *E2ETestSuite) TearDownSuite() { + util.TerminationWaitGroup.Wait() s.T().Log("tearing down e2e test suite") } diff --git a/tests/e2e/machine/suite.go b/tests/e2e/machine/suite.go index 8b267bd..fa58d52 100644 --- a/tests/e2e/machine/suite.go +++ b/tests/e2e/machine/suite.go @@ -5,6 +5,7 @@ import ( clitestutil "github.com/planetmint/planetmint-go/testutil/cli" "github.com/planetmint/planetmint-go/testutil/network" "github.com/planetmint/planetmint-go/testutil/sample" + "github.com/planetmint/planetmint-go/util" machinecli "github.com/planetmint/planetmint-go/x/machine/client/cli" machinetypes "github.com/planetmint/planetmint-go/x/machine/types" @@ -49,6 +50,7 @@ func (s *E2ETestSuite) SetupSuite() { // TearDownSuite clean up after testing func (s *E2ETestSuite) TearDownSuite() { + util.TerminationWaitGroup.Wait() s.T().Log("tearing down e2e test suite") } diff --git a/util/issue_commands.go b/util/issue_commands.go index a8147b8..b46bcd4 100644 --- a/util/issue_commands.go +++ b/util/issue_commands.go @@ -14,7 +14,9 @@ import ( func buildSignBroadcastTx(goCtx context.Context, loggingContext string, sendingValidatorAddress string, msg sdk.Msg) { ctx := sdk.UnwrapSDKContext(goCtx) GetAppLogger().Info(ctx, loggingContext+": "+msg.String()) + TerminationWaitGroup.Add(1) go func() { + defer TerminationWaitGroup.Done() ctx := sdk.UnwrapSDKContext(goCtx) addr := sdk.MustAccAddressFromBech32(sendingValidatorAddress) txJSON, err := lib.BuildUnsignedTx(addr, msg) diff --git a/util/machine_nft_test.go b/util/machine_nft_test.go index 18aa82d..a87a5c8 100644 --- a/util/machine_nft_test.go +++ b/util/machine_nft_test.go @@ -6,6 +6,7 @@ import ( sdk "github.com/cosmos/cosmos-sdk/types" "github.com/planetmint/planetmint-go/testutil/keeper" + "github.com/planetmint/planetmint-go/testutil/moduleobject" "github.com/planetmint/planetmint-go/testutil/sample" "github.com/planetmint/planetmint-go/util" "github.com/planetmint/planetmint-go/util/mocks" @@ -33,7 +34,7 @@ func TestMachineNFTIssuance(t *testing.T) { util.RegisterAssetServiceHTTPClient = &mocks.MockClient{} _, ctx := keeper.MachineKeeper(t) sk, pk := sample.KeyPair() - machine := sample.Machine(pk, pk, sk, "") + machine := moduleobject.Machine(pk, pk, sk, "") goCtx := sdk.WrapSDKContext(ctx) err := util.IssueMachineNFT(goCtx, &machine, "https", "testnet-asset.rddl.io", "/register_asset") diff --git a/util/sync.go b/util/sync.go new file mode 100644 index 0000000..ccb3386 --- /dev/null +++ b/util/sync.go @@ -0,0 +1,5 @@ +package util + +import "sync" + +var TerminationWaitGroup sync.WaitGroup diff --git a/x/machine/keeper/msg_server_attest_machine.go b/x/machine/keeper/msg_server_attest_machine.go index 0a4d6e1..a13449a 100644 --- a/x/machine/keeper/msg_server_attest_machine.go +++ b/x/machine/keeper/msg_server_attest_machine.go @@ -44,7 +44,9 @@ func (k msgServer) AttestMachine(goCtx context.Context, msg *types.MsgAttestMach scheme := params.AssetRegistryScheme domain := params.AssetRegistryDomain path := params.AssetRegistryPath + util.TerminationWaitGroup.Add(1) go func() { + defer util.TerminationWaitGroup.Done() localErr := util.IssueMachineNFT(goCtx, msg.Machine, scheme, domain, path) if localErr != nil { util.GetAppLogger().Error(ctx, "Machine NFT issuance failed : "+localErr.Error())