I'm trying to create an environment where I can test that access to a contract is restricted to a given wallet address, so I'm trying to simulate two users...
1) I'm running geth pointing to Ropsten test network, and have deployed a simple contract with Truffle, which I'm accessing locally via "truffle serve" at http://localhost:8080
2) I have two Chrome instances, "Person 1" and "Person 2" with Metamask wallets set to a separate account in each, both accounts are Ropsten accounts, created in my geth console.
3) When I point the Metamask wallets to the Ropsten network, I can successfully send transactions from each account to my contract and see the values in Ropsten via the etherscan browser, but - I can't successfully make any calls to "constant" functions, everything just returns a zero or a null (ie. in code below I can set the string, but not read it).
I think I'm on the right lines, but don't understand why my calls are not returning any data - anyone encountered similar, or have a good alternative solution to simulate two users?
[UPDATE: My scenario works if I use testrpc instead of Ropsten, so question remains - why can't I make a call to a constant function on Ropsten? ]
Thanks, Iain
contract Message {
address public owner = msg.sender;
string public message = "Initial Message";
function Message() public {
message = "No message set - by constructor";
owner = msg.sender;
}
function retrieveMessage() constant
returns (string _messageString)
{
_messageString = message;
}
function setMessage(string messageString) {
message = messageString;
}
}
Javascript running via http://localhost:8080 served by Truffle...
import message_artifacts from '../../build/contracts/Message.json'
// Messages is our usable abstraction, which we'll use through the code below.
var Messages = contract(message_artifacts);
refreshMessage: function() {
var self = this;
var meta;
Messages.deployed().then(function(instance) {
var result = instance.retrieveMessage.call();
return result;
}).then(function(value) {
var message_element = document.getElementById("secretMessage");
message_element.innerHTML = value + ".";
}).catch(function(e) {
self.setStatus("Error getting message; see log.");
});
}