1

So here's the function that's causing trouble:

function init() {
    require(! isInitialized);
    isInitialized = true;

    bytes32[] storage votableGroups;
    bytes32 fullTimeHash = keccak256('full_time');
    votableGroups.push(fullTimeHash);

    //Initialize voting types
    votingTypeList.push(VotingType({
        name: "Default",
        description: "For initializing",
        quorumPercent: 100,
        minForPercent: 100,
        activeTimeInBlocks: 25,
        goodRepWeight: 1,
        badRepWeight: 1,
        votableGroups: votableGroups
    }));
    votingTypeList[votingTypeList.length - 1].isEligible[fullTimeHash] = true;
}

It always consumes all gas when I'm testing it using Truffle and TestRPC, but it works just fine when I'm using the JavaScript VM in Remix. The function runs fine when I commented out the last two statements.

I can't see anything wrong with my code, so is this caused by a bug in TestRPC?

  • Is votableGroups a contract variable? because it is never initialized otherwise. What is the definition of VotingType? – Ismael Oct 15 '17 at 1:25
  • @Ismael It's a local variable. How do you initialize it? – Zefram Lou Oct 15 '17 at 1:52
  • @Ismael VotingType's definition is struct VotingType { string name; string description; uint quorumPercent; uint minForPercent; //Minimum proportion of for votes needed to pass the voting. uint activeTimeInBlocks; //The number of blocks for which the voting is active. uint goodRepWeight; uint badRepWeight; mapping(address => uint) tokenWeights; //From token's address to weight mapping(bytes32 => bool) isEligible; bytes32[] votableGroups; } – Zefram Lou Oct 15 '17 at 2:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.