Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Converted into a pure Truffle project #9

Merged
merged 21 commits into from
Jun 30, 2017
Merged

Converted into a pure Truffle project #9

merged 21 commits into from
Jun 30, 2017

Conversation

cag
Copy link
Contributor

@cag cag commented Jun 27, 2017

@collinc97 Check it

@cag cag requested a review from Georgi87 June 27, 2017 20:37
var UltimateOracleFactory = artifacts.require("./Oracles/UltimateOracleFactory.sol");
var LMSRMarketMaker = artifacts.require("./MarketMakers/LMSRMarketMaker.sol");
var StandardMarketFactory = artifacts.require("./Markets/StandardMarketFactory.sol");
let Math = artifacts.require('Math')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Get it by symbol and the artifact require call won't worry about filename.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh cool. so this fixes all abstract migration issues?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hope! ^_^'

it('should buy and sell all outcomes', async () => {
// create event
const ipfsHash = 'QmYwAPJzv5CZsnA625s3Xf2nemtYgPpHdWEz79ojWnPbdG'
const oracle = utils.getParamFromTxEvent(
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On tricky thing is getting results for things that cause a state change. Basically you have to look at events that are fired during the transaction to try and get the return value.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interesting. Is that a web3 api call?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. You've already written this actually. I just factored it out into its own function.

Copy link
Contributor

@collinc97 collinc97 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

test looks good. I will use that as a reference going forward

const buyer = 1
const outcome = 0
const token_count = 1e15
const outcome_token_cost = await lmsrMarketMaker.calcCost(market.address, outcome, token_count)
Copy link
Contributor Author

@cag cag Jun 27, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All numbers that come back from contract calls are BigNumbers. I've discovered that you can use them in assert.equal calls directly as long as both args are not BigNumber. You can convert them to plain JS numbers by using the .valueOf() method, or by implicitly casting them via some arithmetic ops. For some reason, if you try to use + with BigNumber and native numbers, you will end up concatenating their decimal representations. WTF.

Anyway, those are my caveats with that type.

@maurelian
Copy link

Are the rest of the tests also going to be converted to JS?

@cag
Copy link
Contributor Author

cag commented Jun 29, 2017 via email

@cag cag changed the title Converted into a pure Truffle project with one ported test Converted into a pure Truffle project Jun 30, 2017
@cag
Copy link
Contributor Author

cag commented Jun 30, 2017

All the tests are rewritten, save for the futarchy oracle test because it doesn't seem like setting the gas limit on TestRPC does anything, the end of the difficulty oracle test because the difficulty of blocks on TestRPC is 0, the lmsr cost function test because it is tested in gnosis.js, and the signed message oracle test.

@collinc97 Turns out web3 is injected by the Truffle framework into tests. I used @digix/tempo to wait. Majority oracle function can be called with an array of addresses.

@collinc97
Copy link
Contributor

Cool. @cag Should I integrate the overloaded math function truffle test into this project? Currently, it is still in gnosis-contracts-truffle. I can also make the test more rigorous.

@cag
Copy link
Contributor Author

cag commented Jun 30, 2017

Awesome, thanks @collinc97

@cag cag merged commit ba8b1cd into master Jun 30, 2017
@cag cag deleted the js-tests-alan branch June 30, 2017 20:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants