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

Adds rest of fetch endpoint functions #26

Merged
merged 33 commits into from
Jul 11, 2022
Merged

Adds rest of fetch endpoint functions #26

merged 33 commits into from
Jul 11, 2022

Conversation

LindaOrtega
Copy link
Contributor

@LindaOrtega LindaOrtega commented Jun 23, 2022

  • Create CommandResult type
  • Add /local function
  • Add /poll function
  • Add /listen function
  • Add /spv function
  • Add /local integration test
  • Add /local unit test (using integration test results)
  • Add /listen integration (devnet and pactserver) and unit tests
  • Add /poll integration (devnet and pactserver) and unit tests
  • Add /spv integration (devnet and pactserver) and unit tests
  • One of these tests should be a continuation to test the edge cases of the Command Result type definition.
  • Refactor against Add api feature #28

NOTE:
There is some indeterminism in the integration tests due to devnet's slow block production.
Increasing the sleep time before listening for a result usually fixes the errors.
I've created an issue here to track this work: #33

UPDATE: Jul 8, 2022
Added exponential backoff and now tests complete more consistently.

@Randynamic
Copy link
Contributor

👌

packages/libs/types/src/PactCommand.d.ts Outdated Show resolved Hide resolved
@LindaOrtega LindaOrtega marked this pull request as ready for review July 8, 2022 05:03
packages/libs/integration-tests/package.json Outdated Show resolved Hide resolved
packages/libs/integration-tests/package.json Outdated Show resolved Hide resolved
packages/libs/kadena.js/src/fetch/tests/local.test.ts Outdated Show resolved Hide resolved
* Request type of /send endpoint.
*
* @param cmds - Non-empty array of Pact commands (or transactions) to submit to server.
*/
Copy link
Member

Choose a reason for hiding this comment

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

I think I've added semver modifiers (@Alpha beta private etc), so they might be there when you rebase.

Comment on lines +192 to +193
} | null;
} | null;
Copy link
Member

Choose a reason for hiding this comment

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

null types are discouraged. They can be replaced by undefined unless they're needed by the API. Then we can parse the undefined to null

Copy link
Contributor

Choose a reason for hiding this comment

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

The current API needs this. We need to discuss this to alter the current API I don't like null either.

txId: number | null;
result: PactResultSuccess | PactResultError;
gas: number;
logs: string | null;
Copy link
Member

Choose a reason for hiding this comment

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

Idem

rush.json Outdated
{
"packageName": "@kadena/integration-tests",
"projectFolder": "packages/libs/integration-tests",
"tags": ["libs"],
Copy link
Member

Choose a reason for hiding this comment

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

Maybe this is more of a "tools" type of package?

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 changed the tag to tools. Should I also move it into the tools subdirectory in /packages?

Copy link
Member

Choose a reason for hiding this comment

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

Yes. Related: maybe we don't need the packages directory and can have the subdirs in the root? What do you think? Packages is common when using a monorepo with sub-packages, but I'm not sure if it has any added value for us

Copy link
Contributor

Choose a reason for hiding this comment

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

using packages gives a bit more overview IMHO if we are going to add dapps in here as well

@@ -39,6 +37,7 @@
"@types/heft-jest": "~1.0.3",
"@types/jest": "^27.5.1",
"@types/node": "^16.0.0",
"concurrently": "^7.2.2"
"concurrently": "^7.2.2",
"exponential-backoff": "~3.1.0"
Copy link
Member

Choose a reason for hiding this comment

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

Is there a specific reason to depend on the ~ only patch updates of this package? Otherwise we might change this to ^. I believe rush install -p <package> in the package directory does that automatically?

Also, I think this should not be a devDependency, as it's needed during the runtime of the package (i.e. running tests)

Comment on lines +91 to +97
describe('[DevNet] Makes /send request to initiate a cross-chain transaction', () => {
test('Receives request key of transaction', async () => {
const actual: SendResponse = await send(sendReq2, devnetApiHostChain0);
const expected: SendResponse = {
requestKeys: [signedCommand2.hash],
};
expect(actual).toEqual(expected);
Copy link
Member

Choose a reason for hiding this comment

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

edit: I see further down that you did add multiple its in one describe, so maybe just ignore this comment if it's intentional

I see you've added describe to all the tests individually. I'm not sure if my explanation was clear enough, that there can be multiple its in one describe. E.g.:

describe('subject under test', () => { 
  it('behaves in a certain way', () => {}); 
  it('behaves in another way with other variables', () => {}); 
})`. 

I'd say subject under test would here be devnet?
And one of the behaviours would be receives request key, on /send request of simple transaction
And another would be: receives the expected transaction result, on /local request of simple transaction

(see attachSignature.test.ts and base64UrlEncode.test.ts )

I'm not yet familiar enough with the context, so this might be semantically incorrect?

Comment on lines +27 to 29
export function message(msg: string): string {
return `Hello, ${msg}!`;
}
Copy link
Member

Choose a reason for hiding this comment

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

This one can be removed. I think it's from a boilerplate or something?

Copy link
Contributor

Choose a reason for hiding this comment

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

yes shall we remove this in another PR as it's currently also in the repo

Comment on lines +1 to 4
import { message } from '../index';

test('check if message add the text hello', () => {
expect(message('Kadena')).toEqual('Hello, Kadena!');
Copy link
Member

Choose a reason for hiding this comment

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

Same here, we don't need this test

Copy link
Member

@alber70g alber70g left a comment

Choose a reason for hiding this comment

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

I've created issues for the open changes, so we can continue

@alber70g alber70g merged commit bc62733 into master Jul 11, 2022
@Randynamic Randynamic deleted the feature/local branch July 12, 2022 11:53
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

4 participants