0

so i have a storage Contract A which has the following mapping and function.

mapping (address => mapping (bytes32 => uint8)) addressToQueryIDToStatus; // 0=no init, 1=init, 2=fail, 3=succeed, auth written, 4=retrieved.
mapping (bytes32 => address) queryIDToAddress; //

function requestAuthorization(bytes32 _queryID, address _sender)
public restricted(msg.sender)
{
    require(_sender != address(0x0));
    require(_queryID[0] != 0);
    addressToQueryIDToStatus[_sender][_queryID] = 1;
    queryIDToAddress[_queryID] = _sender;
    emit LogStorageEventRequestAuthorization("requestAuthorization", _queryID, _sender);
}

which works fine by it self it testing.

I have a second contract B that calls contract A through an interface function below. (i have several of these functions working correctly, but this one has me stumped)

    function requestAuthorization(bytes32 _queryID, address _sender) external;  

calling function:

function requestAuthorization(bytes32 _level, string _input)
public whenNotPaused //IDContractOnly(msg.sender)
returns(bytes32)  
{    
    //require(_level.length > 0, "A");  
    //require(bytes(_input).length > 0,"B");  
    bytes32 queryId = "1";  
   CoinIDStorageInterface(coinIDStorageAddress).requestAuthorization(queryId, msg.sender);
    emit LogNewOraclizeQuery2("Oraclize query with was sent, standing by for the answer for input.. ", msg.sender, queryId, _level, _input);
    return (queryId);
}

with the following test code:

    // this works
    //await coinIDStorageContract.requestAuthorization("1", accounts[1], {from: fromOwner});
    // this doesn't seem to get to storage.
    console.log("Request Auth CoinIDBankContract");
    await coinIDBankContract.requestAuthorization("1", "2085551212", {from: accounts[1]});

    //console.log(returnedQueryID);
    let queryStateCheck = await coinIDStorageContract.requestAuthorizationState("1", accounts[1], {from: fromOwner});
    console.log("CoinIDStorage AuthState: " + queryStateCheck.toNumber());
    //console.log(queryStateCheck)
    let queryState2 = await coinIDBankContract.requestAuthorizationState("1", accounts[1], {from: accounts[1]});

    console.log("CoinIDBank AuthState: " + queryState2);
    assert.equal (queryState2.toNumber(), "1",  "Bank Request of Query State incorrect, should be 1");

with the following results:

CoinIDStorage AuthState: 0
CoinIDBank QueryState: 0
1) CoinIDBank: Auth Request

Events emitted during test:
---------------------------

LogStorageEventRequestAuthorization(functionName: requestAuthorization, _queryID: 0x3100000000000000000000000000000000000000000000000000000000000000, _sender: 0x839c18df17236382f8832d9ab5ef3facafbac891)
LogNewOraclizeQuery2(description: Oraclize query with was sent, standing by for the answer for input.. , _sender: 0x839c18df17236382f8832d9ab5ef3facafbac891, queryId: 0x3100000000000000000000000000000000000000000000000000000000000000, level: 0x1000000000000000000000000000000000000000000000000000000000000000, input: 2085551212)   

So it looks like i have the right values passing, don't get any errors or reverts, and the emits have the right values, HOWEVER, when i check the value, which now should be 1, all i get is the un-itialized 0 state back. If i use the first commented out command, it definitely gets set, and returns the state of 1 which is the intended effect.

Probably something small, but i just don't see it.

this function sets the same value and works in both cases.

    await coinIDStorageContract.returnAuthorizationFail("1", {from: fromOwner});  
    await coinIDBankContract.returnAuthorizationFail("1", {from: fromOwner});  

returning-

CoinIDStorage AuthState: 2
CoinIDBank AuthState: 2

which is correct... still can't see the hangup...

0

the problem was with the testing. I wasn't sending in the same values at each step.

Once I put a 'web3.fromAcii("1") in each spot it worked correctly. I knew it was something small.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.