Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unit tests governance smart contract #2005

Merged
merged 9 commits into from Jun 26, 2020

Conversation

miiu96
Copy link
Contributor

@miiu96 miiu96 commented Jun 24, 2020

Added a lot of unit tests for governance system smart contract also did some fixes in the contract.a

@miiu96 miiu96 requested a review from sasurobert June 24, 2020 05:31
@miiu96 miiu96 self-assigned this Jun 24, 2020
@@ -124,8 +125,7 @@ func (g *governanceContract) init(args *vmcommon.ContractCallInput) vmcommon.Ret

g.eei.SetStorage([]byte(governanceConfigKey), marshaledData)
g.eei.SetStorage([]byte(ownerKey), args.CallerAddr)
g.ownerAddress = make([]byte, 0, len(args.CallerAddr))
g.ownerAddress = append(g.ownerAddress, args.CallerAddr...)
g.ownerAddress = args.CallerAddr
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

leave with complete copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.


retCode := gsc.Execute(callInput)
require.Equal(t, vmcommon.Ok, retCode)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we need another test -> create a general proposal - add multiple voting transactions and one transaction to finalize it. Check in the end the ProposalStatus. This should be done without mocks. For example look in test: TestStakingAuctionSC_ExecuteStakeUnStakeOneBlsPubKeyAndRestake

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@miiu96 miiu96 changed the title Unit tests governance smart contrat Unit tests governance smart contract Jun 25, 2020
import vmcommon "github.com/ElrondNetwork/elrond-vm-common"

// AuctionSCMock -
type AuctionSCMock struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is systemSCstub - as it implements the systemSCinterface

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and you already have SystemSCStub in the mock folder

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

// 3. WhileList a new address, vote with 2 validators with yes and close white list proposal
// 4. Create a new general proposal with new white listed address, vote with 2 validator with yes general proposal
// and close proposal
func TestGovernanceContract_ExecuteProposalCloseProposal(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you might add a function for each step 1, 2, 3 and 4

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

@sasurobert sasurobert merged commit e7bddaf into feat/new-features Jun 26, 2020
@sasurobert sasurobert deleted the unit-tests-governance-sc branch June 26, 2020 16:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants