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

feat: Bee class functionality with error handling #15

Merged
merged 9 commits into from
Dec 8, 2020

Conversation

agazso
Copy link
Member

@agazso agazso commented Dec 2, 2020

This PR adds the low-level module functionality to the Bee class and only exposes that. Therefore passing around the url is no longer necessary because it is encapsulated in the class instance.

Also added error handling for axios responses and some helper types.

Fixes #5
The Buffers are replaced on the interface, but not internally (regarding #10)

test/index.spec.ts Outdated Show resolved Hide resolved
Comment on lines 15 to 25
it('should work with files', async () => {
const content = new Uint8Array([1, 2, 3])
const name = 'hello.txt'

const hash = await bee.uploadFile(name, content)
const file = await bee.downloadFile(hash)

expect(file.name).to.equal(name)
expect(file.data).to.deep.equal(content)
})

it('should retrieve previously created empty tag', async () => {
const tag = await bee.createTag()
const tag2 = await bee.retrieveTag(tag)

expect(tag).to.deep.include(tag2)
})
Copy link
Contributor

Choose a reason for hiding this comment

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

I was wondering if we can just run already define tests in the modules/* but with the Bee instance instead. This seems like unnecessary duplication

Copy link
Member Author

Choose a reason for hiding this comment

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

We can, however the point of this PR is that we no longer expose the modules to the public interface. Instead the Bee class is what we expose to the users of the library, so basically this is the API we are delivering. My intent was to write integration tests for that and also document how to use certain features. Imagine that later when features are removed from the go Bee client we may want to keep these functionalities but their implementation would change.

Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed in the call, the tension here is unnecessary replicating the test code. The proposed solution was to abstract the tests (e.g. similarly to how OpenZeppelin does it https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/test/token/ERC777/ERC777.test.js#L43-L59 )

Copy link
Member Author

Choose a reason for hiding this comment

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

I would postpone this until we have the full Bee functionality and then see what could we test holistically. I imagine that we don't want to duplicate all the tests at the top-level but just make sure that at least they work on the happy path.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sounds good, let's do the test separation later.

src/utils/safeAxios.ts Outdated Show resolved Hide resolved
test/modules/file.spec.ts Outdated Show resolved Hide resolved
src/modules/file.ts Outdated Show resolved Hide resolved
@agazso agazso force-pushed the feat/bee-class-functionality branch 3 times, most recently from b17b963 to a59a3ee Compare December 4, 2020 15:37
@agazso agazso force-pushed the feat/bee-class-functionality branch from 48ed749 to bb4868a Compare December 7, 2020 19:05
Copy link
Contributor

@vojtechsimetka vojtechsimetka left a comment

Choose a reason for hiding this comment

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

LGTM

@agazso agazso merged commit 038f013 into master Dec 8, 2020
@agazso agazso deleted the feat/bee-class-functionality branch December 8, 2020 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error handling
2 participants