From 4da044b5ff5d03cee103a64769215085637cad69 Mon Sep 17 00:00:00 2001 From: Ben Luelo Date: Tue, 15 Feb 2022 15:48:11 -0500 Subject: [PATCH 1/2] Update rpc.md to new integration-tests structure --- docs/rpc.md | 57 +++++++++++++++++++---------------------------------- 1 file changed, 20 insertions(+), 37 deletions(-) diff --git a/docs/rpc.md b/docs/rpc.md index 0302d622f36..1c3432c45da 100644 --- a/docs/rpc.md +++ b/docs/rpc.md @@ -330,15 +330,15 @@ Notes: Technically, it is possible to define `at` anywhere in the RPC definition, but putting it last for all of them makes the RPCs simpler and more consistent. -* If this is a preexisting pallet, they are most likely already defined in the type definitions for `crowdloanRewards` (for reasons that don't need to be covered in this document) and can just be moved over to this file. +* If this is a preexisting pallet, the types for it are most likely already defined in the type definitions for `crowdloanRewards` (for reasons that don't need to be covered in this document) and can just be moved over to this file. Even if there are no types to declare, still define an empty object or else everything will explode. ### Tests -Create a folder here: `integration-tests/runtime-tests/src/tests/rpc/pallet-name` +Create a folder here (if it doesn't already exist): `integration-tests/runtime-tests/test/tests/pallet-name` -And then within that folder, create a file `rpcPalletName.ts` with the following structure: +And then within that folder, create a file `rpcPalletNameTests.ts` with the following structure: ```typescript /* eslint-disable no-trailing-spaces */ @@ -346,47 +346,30 @@ import { /* any custom defined types that are needed for the RPC */ } from '@com import { expect } from 'chai'; -export class RpcPalletNameTests { - /** - * - */ - public static runRpcPalletNameTests() { - describe('rpc.palletName.functionName Tests', function () { - it('STUB', async () => { - const result = await RpcPalletNameTests.rpcPalletNameTest(/* parameters */); - // see note below about bignumbers - // (this is just an example assertion) - expect(result).to.be.a["bignumber"].that.equals('0'); - }); - }); - } +describe('query.palletName.account Tests', function() { + // Set timeout to 1 minute. + this.timeout(60*1000); // <- increaase this if tests are timing out + // repeat this block as needed for every test case defined in the class below. + it('rpc.palletName.functionName Tests', async function() { + await RpcPalletNameTests.rpcPalletNameFunctionNameTest(); + }); +}); + + +export class RpcPalletNameTests { /** * */ - private static async rpcPalletNameTest(/* parameters */) { + public static async rpcPalletNameFunctionNameTest() { // api is a global variable - return await api.rpc.palletName.functionName(/* parameters */); + const result = await api.rpc.palletName.functionName(/* parameters */); + + // see note below about bignumbers + // (this is just an example assertion) + expect(result).to.be.a["bignumber"].that.equals('0'); } } - -// Uncomment to debug -// RpcPalletNameTests.runRpcPalletNameTests(); -``` - -Finally, in `integration-tests/runtime-tests/src/test.ts`, import the above class and add it's tests to the `RPC Tests` test suite: - -```typescript -// ...stub... -import { RpcPalletNameTests } from '@composable/tests/rpc/palletName/rpcPalletNameTests'; // <- add this - -describe('Picasso Runtime Tests', function () { - // ...stub... - describe('RPC Tests', function () { - // ...stub... - RpcPalletNameTests.runRpcPalletNameTests() // <- add this - }); -}); ``` Notes: From dff9f4ff3f5aeb0818df52d6c3d6a1aa2b5588ee Mon Sep 17 00:00:00 2001 From: Ben Luelo Date: Tue, 15 Feb 2022 15:52:20 -0500 Subject: [PATCH 2/2] rename rpc.md to custom-rpcs.md --- docs/{rpc.md => custom-rpcs.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename docs/{rpc.md => custom-rpcs.md} (100%) diff --git a/docs/rpc.md b/docs/custom-rpcs.md similarity index 100% rename from docs/rpc.md rename to docs/custom-rpcs.md