Created
September 11, 2018 12:34
-
-
Save aleph-v/726d9d672b095c7b27c08f3d5ec49a69 to your computer and use it in GitHub Desktop.
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
it('should set prices correctly for multiple buy sell orders for a single crypto', async function () { | |
let price = await this.investment.decodePrices.call([1, 1, 1],"{\"COIN\":{\"USD\":0.1554},\"BTC\":{\"USD\":8180.87}}", true) | |
price[1].should.be.bignumber.equal(toEther(8180.87)) | |
price[2].should.be.bignumber.equal(toEther(8180.87)) | |
price[3].should.be.bignumber.equal(toEther(8180.87)) | |
}) | |
//@Testing Audit - The following tests will fail in the current Oraclize setup | |
it('should set prices correctly for multiple buy sell orders for a single crypto followed by aditional crypto orders', async function () { | |
let price = await this.investment.decodePrices.call([1, 1, 1, 2],"{\"COIN\":{\"USD\":0.1554},\"BTC\":{\"USD\":8180.87},{\"ETH\":{\"USD\":200.87}}", true) | |
price[1].should.be.bignumber.equal(toEther(8180.87)) | |
price[2].should.be.bignumber.equal(toEther(8180.87)) | |
price[3].should.be.bignumber.equal(toEther(8180.87)) | |
price[4].should.be.bignumber.equal(toEther(200.87)) | |
}) | |
//@Testing Audit - The following currently invaild orcalize responses will cause decode prices failures | |
it('should check for invalid api strings with multiple returns for COIN or CASH crypto', async function () { | |
let price = await this.investment.decodePrices.call([1, 10, 1],"{\"COIN\":{\"USD\":0.1554},\"BTC\":{\"USD\":8180.87}, \"COIN\":{\"USD\":0.1554},\"BTC\":{\"USD\":8180.87}}", true) | |
price[1].should.be.bignumber.equal(toEther(8180.87)) | |
price[2].should.be.bignumber.equal(toEther(0.1554)) | |
price[3].should.be.bignumber.equal(toEther(8180.87)) | |
}) | |
it('should check for incorect inverses', async function () { | |
let price = await this.investment.decodePrices.call([1, 11, 2],"{\"COIN\":{\"USD\":0.1554},\"BTC\":{\"USD\":8180.87}, \"BTC\":{\"USD\":8180.87}, \"ETH\":{\"USD\":25000.87}}", true) | |
price[1].should.be.bignumber.equal(toEther(8180.87)) | |
price[2].should.be.bignumber.equal(toEther(1/8180.87)) | |
price[3].should.be.bignumber.equal(toEther(25000.87)) | |
}) | |
it('should fail if any price will be zero', async function () { | |
this.investment.decodePrices.call([1, 2],"{\"COIN\":{\"USD\":0.1554},\"BTC\":{\"USD\":8180.87}", true).should.not.be.fufilled | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment