question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Issue with contract tests

See original GitHub issue

Hi guys!

I’m migrating my tests to embark framework and faced with one issue: Seems like contract don’t have a address in time of tests execution, inspite of deployAll call in before:

var assert = require("assert");
var Embark = require("embark");
var EmbarkSpec = Embark.initTests();
var web3 = EmbarkSpec.web3;

describe("Unitoken", () => {
  before((done) => {
    var contractsConfig = {
      "Unitoken": {
        args: [100000, "Unitoken", 2, "UNI", "0x0"]
      }
    };
    EmbarkSpec.deployAll(contractsConfig, done);
  });

  describe("#symbol()", () => {
    it("should return correct value", (done) => {
        console.log("deployed to: " + Unitoken.address)
        Unitoken.symbol((err, result) => {
          assert.equal(result, "UNI");
          done();
        });
    });
  });
});

and the result of this test:

> univereum@0.0.2 test /home/sayshay/source/univereum
> embark test

  Unitoken
    #symbol()
deployed to: undefined
      1) should return correct value

  0 passing (20s)
  1 failing

  1) Unitoken #symbol() should return correct value:
     Error: invalid address
      at inputAddressFormatter (node_modules/web3/lib/web3/formatters.js:271:11)
      at inputCallFormatter (node_modules/web3/lib/web3/formatters.js:75:22)
      at node_modules/web3/lib/web3/method.js:89:28
      at Array.map (native)
      at Method.formatInput (node_modules/web3/lib/web3/method.js:88:32)
      at Method.toPayload (node_modules/web3/lib/web3/method.js:114:23)
      at Eth.send [as call] (node_modules/web3/lib/web3/method.js:139:30)
      at SolidityFunction.call (node_modules/web3/lib/web3/function.js:118:15)
      at SolidityFunction.execute (node_modules/web3/lib/web3/function.js:238:22)
      at Context.it (test/contract_spec.js:19:18)

Please notice deployed to: undefined log output, which is refers to Unitoken.address Am I doing something wrong?

Link to file in repo

Thanks in advance

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Reactions:1
  • Comments:5

github_iconTop GitHub Comments

1reaction
frostiqcommented, Mar 13, 2017

can be fixed like this:

var contractsConfig = {
      "Unitoken": {
        gas: 4712388,
        args: [100000, "Unitoken", 2, "UNI", "0x0"]
      }
    };

But it will be really nice if somebody will be able to improve auto gas calculation, so this dirty hack will not be needed 😃

0reactions
iurimatiascommented, Jun 22, 2018

Closing this as it’s somewhat outdated. Gas calculation and the testing framework is vastly improved in Status Embark 3.1 (http://embark.status.im/)

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is Contract Testing & How is it Used? - Pactflow
can be unreliable or flakey. Because of the complexity in orchestrating a test environment, they can often fail, causing false-positives and ...
Read more >
Introduction To Pact Contract Testing With Examples
Contract testing is a method to verify integration between two applications independently in order to test what has been passed and see if...
Read more >
Your Contract Tests Are Not Protecting You | by Harry Martland
On numerous occasions I've heard people say they are doing contract tests or that contract testing can help solve their problems.
Read more >
Why contract testing can be essential for microservices
The problem with microservices integration testing · Too many integrations to test. · Mismatched microservice versions. · Lack of clear testing ...
Read more >
End-to-end vs. contract-based testing: How to choose
Contract -based tests typically won't detect endpoint configuration issues or misused classes. Other types of testing cover those errors and catch those types...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found