Skip to content

Commit

Permalink
fix: last test
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Nov 29, 2024
1 parent be3786a commit 598acac
Showing 1 changed file with 0 additions and 106 deletions.
106 changes: 0 additions & 106 deletions interchaintest/provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -439,109 +439,3 @@ func (s *ProviderSuite) TestProviderRemoveConsumer() {
_, err = s.Provider.GetConsumerGenesis(s.GetContext(), consumerChain.ConsumerID)
s.Require().Error(err)
}

// Confirm that only the owner can send MsgUpdateConsumer, MsgRemoveConsumer
// Confirm that ownership can be transferred to a different address -> results in the "old" owner losing ownership
func (s *ProviderSuite) TestProviderOwnerChecks() {
testAcc1 := s.Provider.TestWallets[9].FormattedAddress()
testAcc2 := s.Provider.TestWallets[10].FormattedAddress()
testAccKey1 := s.Provider.TestWallets[9].KeyName()
testAccKey2 := s.Provider.TestWallets[10].KeyName()
// Create an opt-in chain
chainName := "providerOwnerChecks-1"
createMsg := msgCreateConsumer(chainName, nil, nil, testAcc1)

// create consumer with owner set to test account 1
consumerId, err := s.Provider.CreateConsumer(s.GetContext(), createMsg, testAccKey1)
s.Require().NoError(err)
s.Require().NoError(s.Provider.OptIn(s.GetContext(), consumerId, 0))

// try to update the consumer with the test account 2 - fails
spawnTime := time.Now().Add(time.Hour)
initParams := consumerInitParamsTemplate(&spawnTime)
powerShapingParams := powerShapingParamsTemplate()
upgradeMsg := &providertypes.MsgUpdateConsumer{
Owner: testAcc1,
ConsumerId: consumerId,
NewOwnerAddress: testAcc2,
InitializationParameters: initParams,
PowerShapingParameters: powerShapingParams,
}
err = s.Provider.UpdateConsumer(s.GetContext(), upgradeMsg, testAccKey2)
s.Require().Error(err)
s.Require().Contains(err.Error(), "unauthorized")

// try to update the consumer with the test account 1 - passes
initParams.SpawnTime = time.Now()
upgradeMsg = &providertypes.MsgUpdateConsumer{
Owner: testAcc1,
ConsumerId: consumerId,
NewOwnerAddress: testAcc1,
InitializationParameters: initParams,
PowerShapingParameters: powerShapingParams,
}
s.Require().NoError(s.Provider.UpdateConsumer(s.GetContext(), upgradeMsg, testAccKey1))
consumerChain, err := s.Provider.GetConsumerChain(s.GetContext(), consumerId)
s.Require().NoError(err)
s.Require().Equal(providertypes.CONSUMER_PHASE_LAUNCHED.String(), consumerChain.Phase)
s.Require().Equal(testAcc1, consumerChain.OwnerAddress)

// cannot be removed if the sender is not owner
err = s.Provider.RemoveConsumer(s.GetContext(), consumerChain.ConsumerID, testAccKey2)
s.Require().Error(err)
s.Require().Contains(err.Error(), "unauthorized")

// transfer ownership
upgradeMsg = &providertypes.MsgUpdateConsumer{
Owner: testAcc1,
ConsumerId: consumerId,
NewOwnerAddress: testAcc2,
}
s.Require().NoError(s.Provider.UpdateConsumer(s.GetContext(), upgradeMsg, testAccKey1))
consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId)
s.Require().NoError(err)
s.Require().Equal(providertypes.CONSUMER_PHASE_LAUNCHED.String(), consumerChain.Phase)
s.Require().Equal(testAcc2, consumerChain.OwnerAddress)

// old owner lost ownership
err = s.Provider.RemoveConsumer(s.GetContext(), consumerChain.ConsumerID, testAccKey1)
s.Require().Error(err)
s.Require().Contains(err.Error(), "unauthorized")

// update to topN chain not allowed if owner is not gov module
powerShapingParams.Top_N = 80
upgradeMsg = &providertypes.MsgUpdateConsumer{
Owner: testAcc2,
NewOwnerAddress: testAcc2,
ConsumerId: consumerId,
PowerShapingParameters: powerShapingParams,
}
s.Require().Error(s.Provider.UpdateConsumer(s.GetContext(), upgradeMsg, testAccKey2))

// update owner using proposal is not possible - current owner is among expected signers
upgradeMsg = &providertypes.MsgUpdateConsumer{
Owner: testAcc2,
NewOwnerAddress: chainsuite.GovModuleAddress,
ConsumerId: consumerId,
}
err = s.Provider.ExecuteProposalMsg(s.GetContext(), upgradeMsg, chainsuite.GovModuleAddress, chainName, cosmos.ProposalVoteYes, govv1.StatusPassed, false)
s.Require().Error(err)
s.Require().Contains(err.Error(), "expected gov account")

// update owner using msg submited by the current owner
s.Require().NoError(s.Provider.UpdateConsumer(s.GetContext(), upgradeMsg, testAccKey2))

// update to top N using proposal
upgradeMsg = &providertypes.MsgUpdateConsumer{
Owner: chainsuite.GovModuleAddress,
NewOwnerAddress: chainsuite.GovModuleAddress,
ConsumerId: consumerId,
PowerShapingParameters: powerShapingParams,
}
s.Require().NoError(s.Provider.ExecuteProposalMsg(s.GetContext(), upgradeMsg, chainsuite.GovModuleAddress, chainName, cosmos.ProposalVoteYes, govv1.StatusPassed, false))
consumerChain, err = s.Provider.GetConsumerChain(s.GetContext(), consumerId)
s.Require().NoError(err)
s.Require().Equal(providertypes.CONSUMER_PHASE_LAUNCHED.String(), consumerChain.Phase)
s.Require().Equal(powerShapingParams.Top_N, uint32(consumerChain.PowerShapingParams.TopN))
s.Require().Equal(chainsuite.GovModuleAddress, consumerChain.OwnerAddress)
}

0 comments on commit 598acac

Please sign in to comment.