-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add to Exchange features imported from DexTrade (#20)
* Add code from abandoned Trade smart contract * Add initial unit test
- Loading branch information
Showing
2 changed files
with
83 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,53 @@ | ||
module.exports = function (glob) { | ||
describe("Exchange", function () { | ||
it("T001: TO-DO", function (done) { | ||
done(); | ||
}); | ||
}); | ||
const chai = require('chai'); | ||
const chaiAsPromised = require("chai-as-promised"); | ||
const Exchange = artifacts.require('Exchange'); | ||
|
||
chai.use(chaiAsPromised); | ||
chai.should(); | ||
|
||
module.exports = (glob) => { | ||
describe('Exchange', () => { | ||
|
||
let instance = null; | ||
|
||
before(async () => { | ||
instance = await Exchange.deployed(); | ||
}); | ||
|
||
describe('constructor', () => { | ||
it('should initialize fields', async () => { | ||
const owner = await instance.owner.call(); | ||
owner.should.equal(glob.owner); | ||
}); | ||
}); | ||
|
||
describe('owner()', () => { | ||
it('should equal value initialized at construction time', async () => { | ||
const owner = await instance.owner.call(); | ||
owner.should.equal(glob.owner); | ||
}); | ||
}); | ||
|
||
describe('changeOwner()', () => { | ||
describe('if called with current owner as sender', () => { | ||
after(async () => { | ||
await instance.changeOwner(glob.owner, {from: glob.user_a}); | ||
}); | ||
|
||
it('should successfully set new owner and emit event', async () => { | ||
const result = await instance.changeOwner(glob.user_a); | ||
result.logs.should.be.an('array').and.have.lengthOf(1); | ||
result.logs[0].event.should.equal('OwnerChangedEvent'); | ||
const owner = await instance.owner.call(); | ||
owner.should.equal(glob.user_a); | ||
}); | ||
}); | ||
|
||
describe('if called with sender that is not current owner', () => { | ||
it('should fail to set new owner', async () => { | ||
instance.changeOwner(glob.user_a, {from: glob.user_a}).should.be.rejected; | ||
}); | ||
}); | ||
}); | ||
}); | ||
}; |