Skip to content

Commit

Permalink
Deploy Contract on unittest
Browse files Browse the repository at this point in the history
  • Loading branch information
LeoBurn committed Oct 13, 2022
1 parent 3fa3741 commit 6f67009
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"scripts": {
"test": "mocha"
},
"author": "",
"license": "ISC",
"author": "Leandro Viana",
"license": "MIT",
"dependencies": {
"@truffle/hdwallet-provider": "^1.5.1",
"ganache-cli": "^6.12.2",
Expand Down
26 changes: 25 additions & 1 deletion test/Inbox.test.js
Original file line number Diff line number Diff line change
@@ -1 +1,25 @@
// contract test code will go here
const assert = require('assert');
const ganache = require ('ganache-cli');
const Web3 = require('web3');
const web3 = new Web3(ganache.provider());
const { interface, bytecode} = require('../compile');


let accounts;
let inbox;
beforeEach(async () => {
//Get a list of all accounts

accounts = await web3.eth.getAccounts();
//User one of those account to deploy
// the contract
inbox = await new web3.eth.Contract(JSON.parse(interface))
.deploy({data: bytecode, arguments: ['Hi there!']})
.send({from: accounts[0],gas:1000000});
});

describe('Inbox',() => {
it('should deploy the contract',()=> {
console.log(inbox);
})
})

0 comments on commit 6f67009

Please sign in to comment.