Skip to content

Grant/issue10 #55

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

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Grant/issue10 #55

wants to merge 9 commits into from

Conversation

theRealBitcoinClub
Copy link

closes #10


const result = await bchjs.Ninsight.details(addr)
//console.log(`result: ${JSON.stringify(result, null, 2)}`)
assert.property(result[0], "balance")
Copy link
Collaborator

Choose a reason for hiding this comment

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

check first if it is Array assert.isArray(result)

}
})

it(`should GET details for a single address`, async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should POST details

assert.property(result, "pagesTotal")
})

it(`should GET details for an array of addresses`, async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should POST - it is getting details via POST method

Copy link
Author

Choose a reason for hiding this comment

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

ty

it(`should GET details for a single address`, async () => {
// Stub the network call.
sandbox.stub(axios, "post").resolves({
data: mockData.addrDetail
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is strange. According to your integration tests both single address and multiply addresses returns Array (cause they are both using POST, this is different from original BitBox call), so should be addrDetailArray here...

Copy link
Author

Choose a reason for hiding this comment

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

OK, I also realized that and then I thought it could be a feature not a bug :)? maybe the API is easier to use if the return type is always the same? What do you think? Would it make sense to change the API in that direction? I can also just implement it differently, but that would also add more code complexity. I think on both sides of the interface varying return types would add complexity. Please tell me what to do! I am just brainstorming here.

Copy link
Collaborator

Choose a reason for hiding this comment

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

bch-js is just a JS wrapper for accessing to bch-api. API is already implemented and already running, so pretty much you cannot decide by yourself should it be GET or POST and should it be array or no. In this case API is POST requests for both single and multiply addresses, returning Array. So that should be bch-js implementing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

A, also maybe you need to rebase from master again - "This branch is out-of-date with the base branch" message below

Copy link
Author

Choose a reason for hiding this comment

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

I changed to mock addrDetailArray Is it ok now?

In the issue description there is something written about POST:

Porting the code should meet the following requirements:

The code should follow the same pattern as the existing utxo() method, but should only use the POST call to the REST API. This should include api-doc documentation.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Seems good to me. But I'm just another junior developer. Chris will have the last word as a senior developer and product owner.

Copy link
Author

Choose a reason for hiding this comment

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

@zh thanks for taking the time to review @christroutner what do you think, can we put a check mark on this one?

@theRealBitcoinClub
Copy link
Author

@zh POST, isArray check, 100% test

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.

Add Ninsight Balances to bch-js
2 participants