5

I'm using Dapple (http://dapple.readthedocs.io) specifically the test framework. I have the following contract

contract App {
  bytes1 public myVar;
  function App() {
    myVar = 0x01;
  }
}

and the following test

function test() {
  bytes1 variable1 = App(proxy_tester).myVar();
  bytes1 a = 0x01;
  assertEq1(variable1, a);
}

I would expect this test to pass, instead it fails with this

| Error: Wrong `bytes1' value
|   Expected: 0x01
|     Actual: 0xc6

I'm supposing 0xc6 is just a random value in memory or a wrong encoding of 0x01.

What am I doing wrong?

Note: dapple does not run in a blockchain but directly in a virtual machine. I tried this code in truffle and it works as expected.

2

First of all I'm assuming you have a local App and a setUp function that looks like this:

App app;
function setUp() {
    app = new App();
    proxy_actor._target(app);
}

This almost works, but he issue here is that the proxy actor cannot return values due to some EVM contraints. It is only for mocking the sender. Ideally it would also proxy the return value, but there are some EVM constraints that don't allow this.

In this case, the return value does not depend on the sender at all, so you could just test it directly (the sender will be the Test contract instead of the proxy actor):

function test() {
  bytes1 variable1 = app.myVar();
  bytes1 a = 0x01;
  assertEq1(variable1, a);
}

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.