solidity enum VotingSystem { MEMBERSHIP, NETWORKGOVERNANCETOKEN, ANY_TOKEN } struct…
- User
solidity enum VotingSystem { MEMBERSHIP, NETWORK_GOVERNANCE_TOKEN, ANY_TOKEN } struct VotingToken { uint256 chainId; address token; address balanceType; // voting power strategy // address 1 // address 2 }
codestruct VotingSystemTokenCheckpoint { uint256 fromBlock; VotingToken[] votingTokens; } struct VotingSystemLayout { VotingSystemTokenCheckpoint[] checkpoints; mapping(uint256 /* current chain blockNumber */ => mapping(uint256 /* chainId */ => uint256)) otherChainBlockNumbers; }function setVotingSystem( VotingSystem vs, VotingToken[] memory votingTokens ) external { SettingsStorage.justSetUint256Setting(VOTING_SYSTEM_SETTING_KEY, uint256(vs)); if (vs == VotingSystem.MEMBERSHIP) { VotingToken[] memory emptyArray = new VotingToken; _setVotingTokens(emptyArray); emit VotingSystemTokensUpdated(emptyArray); } else { IVotingPowerTypeRegistry votingPowerTypeRegistry = IVotingPowerTypeRegistry( SettingsStorage.getAddressSetting(VOTING_POWER_TYPE_REGISTRY_ADDRESS) ); unchecked { for (uint256 i = 0; i < votingTokens.length; i++) { require( votingPowerTypeRegistry.isVotingPowerType(votingTokens[i].balanceType), "WRONG_BALANCE_TYPE_ADDRESS" ); if (vs == VotingSystem.NETWORK_GOVERNANCE_TOKEN) { require(votingTokens[i].chainId == block.chainid, "WRONG_CHAIN_ID"); } } } _setVotingTokens(votingTokens); emit VotingSystemTokensUpdated(votingTokens); } } write python test for setVotingSystem
- Assistant
I can provide you with a Python test framework using the
unittestmodule to test thesetVotingSystemfunction. Here's an example:python - User
rewrite for brownie framework with pytest
- Assistant
Certainly! Here's an example of how you can write the test for the
setVotingSystemfunction using the Brownie framework with pytest:python - User
eth_abi.exceptions.NoEntriesFound: No matching entries for 'tuple' in encoder registry
- Assistant
Apologies for the confusion. It seems that you're encountering an error related to ABI encoding using the
eth_abilibrary. In this case, it appears that the library is not recognizing thetupledata type in the ABI.To resolve this issue, you can manually encode the data for the struct using the function. Here's an updated version of the test code with the necessary modifications: