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
Conversation
@@ -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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
leave with complete copy.
There was a problem hiding this comment.
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) | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
vm/mock/auctionSCMock.go
Outdated
import vmcommon "github.com/ElrondNetwork/elrond-vm-common" | ||
|
||
// AuctionSCMock - | ||
type AuctionSCMock struct { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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) { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done.
Added a lot of unit tests for governance system smart contract also did some fixes in the contract.a