This is my first experience with eoslime as I want to do unit testing for smart contracts. Not much experienced with nodejs .I am following eoslime documentation: https://docs.eoslime.limechain.tech/examples

I added user smart contract file in eoslime contracts directory. eoslime compile and eoslime deploy commands are going okay. eoslime nodeos is running. Following is my test file:

const assert = require('assert');

const TOKEN_WASM_PATH = './contracts/user/user.wasm';
const TOKEN_ABI_PATH = './contracts/user/user.abi';

describe("EOSIO User", function (eoslime) {

    // Increase mocha(testing framework) time, otherwise tests fails

    let userContract;
        let userTable;
        let adminAccount;

    before(async () => {

            adminAccount = await eoslime.Account.load('accname','PK');

    beforeEach(async () => {

        userContract = await eoslime.Contract.deploy(TOKEN_WASM_PATH, TOKEN_ABI_PATH);
        userTable = userContract.users;

    it("Should create a new user", async () => {
             await userContract.upsertuser("123","123","123","123","123","123",1, ["grp1"], { from: adminAccount.name });

    it("Should check user", async () => {

        let messages = await userTable.limit(10).find();
        messages = await userTable.equal(adminAccount.name).find();
        assert.equal(messages.length, 0, "Should not have any rows yet");
        const message = messages[0];
        assert.equal(message.created_by, adminAccount.name, "account name not correct");


    it("Should remove user", async () => {
            await userContract.eraseuser("123", { from: adminAccount.name });


Here, upsertuser is the action name which inserts data in multi-index table. While testing it does not give any error. The error is getting generated by it("Should check user", async () => { and it("Should remove user", async () => { because the data is not getting saved in table. The abi file contains this table:

"tables": [
            "name": "users",
            "type": "usertable",
            "index_type": "i64",
            "key_names": [],
            "key_types": []

Can anybody help, where I am mistaken? And how to check table data and transactions on chain?

1 Answer 1


the problem is coming from beforeEach function => you are deploying each time a new contract and it throws, because you are creating your user only in the first test suite


  1. Replace beforeEach with before

  2. Create a user in each of your tests

  • can you please give suggestions how to check table data in test? Your answer solves the problem for deleting data but still gives error for it("Should check user", async ()
    – Varsh
    Commented Jun 12, 2020 at 2:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.