I can get the AddPerson() work on the actual private ethereum network. But when I call AddPerson() on testrpc, it gives me :
"callback contain no result Error: VM Exception while processing transaction: invalid opcode" message.
I use the remix browser compiler to compile and deploy.
I checked the gas etc. etc. but it just does not work on testrpc.
Any help will be appreciated
pragma solidity ^0.4.15;
library MyLib {
struct Person {
uint balance ;
}
struct PersonsData {
mapping(address => Person) person ;
uint numpersons ;
}
function MyLibInit(PersonsData storage self) {
self.numpersons = 0 ;
}
function AddPerson(PersonsData storage self) public {
Person memory p ;
p.balance = 0 ;
self.person[msg.sender] = p;
self.numpersons++ ;
}
}
contract PersonContract {
using MyLib for MyLib.PersonsData ;
MyLib.PersonsData mypersons ;
function PersonContract() payable {
mypersons.MyLibInit() ;
}
function () {
revert() ;
}
function AddPerson() payable public {
mypersons.AddPerson() ;
}
}