First of all, sorry for the code in Portuguese, this was a choice of the team and I had no saying on that.
I'm writing a Billet Manager, the code is as follows:
contract GerenciadorBoletos {
struct Boleto {
uint codigoBarra;
uint codigoBarraDigitavel;
uint cpfOuCnpjBeneficiario;
uint cpfOuCnpjPagador;
uint valorOriginal;
uint dataVencimento;
}
mapping(uint => Boleto) registroBoletos;
function inserirBoleto(
uint codigoBarra,
uint codigoBarraDigitavel,
uint cpfOuCnpjBeneficiario,
uint cpfOuCnpjPagador,
uint valorOriginal,
uint dataVencimento
) {
Boleto memory b = Boleto(
codigoBarra,
codigoBarraDigitavel,
cpfOuCnpjBeneficiario,
cpfOuCnpjPagador,
valorOriginal,
dataVencimento
);
// I need to do some validations before store it, but there is no code yet
registroBoletos[b.codigoBarra] = b;
}
}
I'm testing it with TestRPC and Mocha:
describe('1. Inserção', function(){
it('Deve ter inserido um boleto com os dados válidos com sucesso', function(done){
var boletoParaInserir = gerarBoletoValido();
console.log(boletoParaInserir);
gerenciadorBoleto.inserirBoleto.sendTransaction(
9872387128, 987128382, 91289312, 81273818, 50, Date.now() + 3*24*3600,
{
from: web3.eth.accounts[0],
gas: 3000000,
},
function(e, result) {
expect(e).to.not.exist;
expect(result).to.exist;
result.should.be.above(0);
}
);
});
});
I'm getting the following error:
Uncaught AssertionError: expected [Error: Error: VM Exception while executing transaction: invalid opcode
Edit
This seems to be an issue with TestRPC.
I've opened an issue on github.