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

Http api 1.0 rc changes #39

Merged
merged 15 commits into from
Jun 21, 2017
Merged

Http api 1.0 rc changes #39

merged 15 commits into from
Jun 21, 2017

Conversation

TimDaub
Copy link
Contributor

@TimDaub TimDaub commented Jun 19, 2017

  • Changes the Connection model to the agreed on HTTP API breaking changes as outlines here
  • adds tests for all changes
  • adds sinon.js for mocking
  • changed path describing keys to camelCase
  • added constant.js (similar to conftest.py)
  • added integration tests that run against bdb
  • updated ascribe-eslint package
  • test and fix asset endpoint
  • test and fix outputs endpoint

More info:

@TimDaub TimDaub requested review from ssadler and vrde June 19, 2017 12:42
@TimDaub TimDaub force-pushed the http-api-1.0-rc-changes branch 7 times, most recently from c747533 to 9a73fc1 Compare June 20, 2017 09:06


// TODO: Find out how to mock `request`
test.skip('Request with custom headers', t => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Import/export from parent module (index.js)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed this

@TimDaub TimDaub force-pushed the http-api-1.0-rc-changes branch from 9a73fc1 to 5c92661 Compare June 20, 2017 15:47
@TimDaub
Copy link
Contributor Author

TimDaub commented Jun 20, 2017

Add integration test for asset endpoint :diamond:

:(

@TimDaub
Copy link
Contributor Author

TimDaub commented Jun 20, 2017

Please note that in Connection.js I broke the interface to use camelCased parameters for some methods already.

For an example, see this:

It will require me to fix the rest of those before releasing a 1.0 compatible release.

I just finished this with de072dc and 9191745.

@TimDaub TimDaub force-pushed the http-api-1.0-rc-changes branch from e1d0f21 to b883e1f Compare June 21, 2017 11:28
@codecov-io
Copy link

codecov-io commented Jun 21, 2017

Codecov Report

Merging #39 into master will increase coverage by 18.16%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #39       +/-   ##
==========================================
+ Coverage   50.53%   68.7%   +18.16%     
==========================================
  Files          21      21               
  Lines         279     278        -1     
==========================================
+ Hits          141     191       +50     
+ Misses        138      87       -51
Impacted Files Coverage Δ
...saction/serializeTransactionIntoCanonicalString.js 100% <ø> (ø) ⬆️
src/connection/index.js 93.54% <100%> (+65.42%) ⬆️
src/baseRequest.js 75% <0%> (+21.42%) ⬆️
src/format_text.js 36.36% <0%> (+27.27%) ⬆️
src/stringify_as_query_param.js 90% <0%> (+60%) ⬆️
src/sanitize.js 73.68% <0%> (+63.15%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8cde6df...1aa430a. Read the comment docs.

Copy link
Contributor

@vrde vrde left a comment

Choose a reason for hiding this comment

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

Apart from the first test in test/connection/test_connection.js, I'm not sure I understand how the rest of the tests in the same file work.

The file test/constants.js contains a mixture of constants and functions that returns variable values. I think hard-coding Alice's pubkey (and outputs) is not a good idea since tests run in parallel. In this case we can have problems processing the unspents—e.g. I want to create a test where I transfer something from Alice to Bob. If Bob's pubkey is constant, tests can influence each others and assertions like:

  • unspentst-1(Bob) = unspentst(Bob) + 1

can easily fail.

@@ -8,16 +8,15 @@ export default class Connection {
}

getApiUrls(endpoints) {
Copy link
Contributor

Choose a reason for hiding this comment

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

endpointsendpoint (singular)

@@ -128,12 +133,10 @@ export default class Connection {
const timer = setInterval(() => {
this.getStatus(txId)
.then((res) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove extra parenthesis 💅

@@ -128,12 +133,10 @@ export default class Connection {
const timer = setInterval(() => {
this.getStatus(txId)
.then((res) => {
console.log('Fetched transaction status:', res) // eslint-disable-line no-console
if (res.status === 'valid') {
clearInterval(timer)
this.getTransaction(txId)
.then((res_) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove extra parenthesis 💅

'transactionsDetail': 'transactions/%(transactionId)s',
'assets': 'assets',
}
Object.keys(endpoints).forEach((endpointName) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

remove extra parenthesis 💅

// TODO: Find out if ava has something like conftest, if so put this there.

// NOTE: We cast `Math.random()` to a string, as sometimes Javascript simply
// yields a slightly different float during runtime, lol
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean by "slightly different float"?

@TimDaub
Copy link
Contributor Author

TimDaub commented Jun 21, 2017

Apart from the first test in test/connection/test_connection.js, I'm not sure I understand how the rest of the tests in the same file work.

They check if for given input parameters, the tested function calls the request method correctly.
For example click here. Note that a boolean is passed to the function, but a string comes out.

I think hard-coding Alice's pubkey (and outputs) is not a good idea since tests run in parallel. In this case we can have problems processing the unspents—e.g. I want to create a test where I transfer something from Alice to Bob. If Bob's pubkey is constant, tests can influence each others and assertions like:

unspentst-1(Bob) = unspentst(Bob) + 1
can easily fail.

OK, I can fix this.

@TimDaub
Copy link
Contributor Author

TimDaub commented Jun 21, 2017

remove extra parenthesis 💅

ascribe/javascript#56


const createTx = Transaction.makeCreateTransaction(
asset(),
metaData,
[aliceOutput, aliceOutput],
alice.publicKey
[carolOutput, carolOutput],
Copy link
Contributor

Choose a reason for hiding this comment

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

who is Carol?

@ssadler
Copy link
Contributor

ssadler commented Jun 21, 2017

Why is it connection/index.js rather than just connection.js?

@TimDaub
Copy link
Contributor Author

TimDaub commented Jun 21, 2017

Why is it connection/index.js rather than just connection.js?

#57

@TimDaub TimDaub merged commit b8d73b2 into master Jun 21, 2017
@kremalicious kremalicious deleted the http-api-1.0-rc-changes branch June 28, 2017 15:04
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.

For connection.js, in all methods use camelCase named parameters (and preferably no objects)
4 participants