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

Provide Test Cases for Web3 1.0 Support #3618

Closed
ghost opened this issue Mar 19, 2018 · 5 comments
Closed

Provide Test Cases for Web3 1.0 Support #3618

ghost opened this issue Mar 19, 2018 · 5 comments

Comments

@ghost
Copy link

ghost commented Mar 19, 2018

affects #3642 and MetaMask/web3-provider-engine#189

In order to clarify the implementation-requirements of the web3 1.0 support, test-cases should be provided.

The test-cases can be used for both web3 1.0 support implementation paths:

Step One

Provide simple js code files, which demonstrate the web3 1.0 access (which should fail)

from #3642 (comment)

// Importing the latest version from NPM
const Web3 = require('web3')

// initializing a local instance
const web3 = new Web3(window.web3.currentProvider)
web3.eth.subscribe('logs', {
  address: '0x86fa049857e0209aa7d9e616f7eb3b3b78ecfdb0',  // EOS token is popular atm.
  topics: [], // A token transfer log would be good for now.
}, function (err, result) {
  if (err) throw err
  console.log('Success!', result)
})

Step Two

Embed those code files into the MM test system.

Draft/Starting-Point: https://gist.github.com/ryan-rowland/54218bde11170734acb276a3564ac06b

References

from: #3618 (comment)

web3 original test-cases

https://github.com/ethereum/web3.js/blob/1.0/test/helpers/test.subscription.js
https://github.com/ethereum/web3.js/blob/1.0/test/eth.subscribe.js

Subscription relevant specs:

https://web3js.readthedocs.io/en/1.0/web3-eth-subscribe.html

@ghost ghost mentioned this issue Mar 19, 2018
1 task
@ryan-rowland
Copy link
Contributor

ryan-rowland commented Mar 21, 2018

Here are the tests web3.js is running against their own provider to test subscriptions:
https://github.com/ethereum/web3.js/blob/1.0/test/helpers/test.subscription.js
https://github.com/ethereum/web3.js/blob/1.0/test/eth.subscribe.js

And the specs for eth.subscribe(), eth.clearSubscriptions() and the Subscription object:
https://web3js.readthedocs.io/en/1.0/web3-eth-subscribe.html

@ryan-rowland
Copy link
Contributor

ryan-rowland commented Mar 21, 2018

Here's a first pass at a draft of Step A. Some of the actual tests are filled in, but toward the bottom there are some empty tests just outlining what needs to be validated.

https://gist.github.com/ryan-rowland/54218bde11170734acb276a3564ac06b

@ghost
Copy link
Author

ghost commented Mar 21, 2018

@ryan-rowland , very nice! I've updated the document. At this point it should be much easier for anyone to get started.

@ryan-rowland
Copy link
Contributor

Running some tests locally using web3 on npm against rinkeby. Some of my initial assumptions were wrong, particularly regarding the subscribe callback. It actually runs every time a data event fires with (err, data, subscription). The web3 docs aren't very thorough in this regard.

I'll update later when I have time.

@ghost
Copy link
Author

ghost commented Apr 14, 2018

@ryan-rowland , i'm closing down here. For the case you still want to push this, just go on please.

follow-up MetaMask/web3-provider-engine#189 & #3642

@ghost ghost closed this as completed Apr 14, 2018
This issue was closed.
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

No branches or pull requests

1 participant