0

Given a contract with an event as follows

contract test {
    event LogEvent(
        address a,
        bool result
    );    

    function testInputs(some parameters) public (){

        ....

        //set it to pass the if condition
        bool[2] a = [true,true]; 

        //set it to fail the if condition
        //bool[2] a = [false,true]; 

        if(a[1] && a[2])
            LogEvent(msg.sender,true);
        else
            LogEvent(msg.sender,false);
    }  
}

I initially transact and set the parameters so that the if condition is satisfied and the event fires true.

I then transact again and set the parameters so that the if condition does not pass. I expect a new event to be fired setting the value to false.

However, the value remains true when I check the log. I believe that each event fired should permanently store the value with the transaction. Is that incorrect?

I also tried testing this the other way around. I started with a transaction that fires the event setting it to false. That works. Then I transact again, setting it to true. Again, that works. However, if I try transacting with incorrect parameters once more, it does not set back to false when I check the log.

Can someone provide an explanation and how to work around that issue?

  • Could you please post the actual condition and the code leading up to it? – Henk Jul 4 '18 at 18:04
  • @Henk the condition is as simple as the update I just added to the code. – blockchainenth Jul 4 '18 at 18:14
  • @Henk yeah, I change it so that it can pass/not pass the if condition. – blockchainenth Jul 4 '18 at 18:25

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.