Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 104 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,15 @@ composable-node = { path = "node", features = ["composable", "dali"] }
color-eyre = { version = "0.5.11", default-features = false }

[features]
runtime-benchmarks = ["composable-node/runtime-benchmarks"]
std = ["composable-node/std"]
runtime-benchmarks = [ "composable-node/runtime-benchmarks" ]
std = [ "composable-node/std" ]
local-integration-tests = []

[workspace]
exclude = ["frame/transaction-fee"]
members = [
"frame/*",

"integration-tests/local-integration-tests",
"node",

"runtime/common",
Expand Down
7 changes: 7 additions & 0 deletions Makefile.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,11 @@ script = '''
cargo run --release -- --version
cd ../polkadot && cargo run --release -- --version && pwd && cd ../composable
cd scripts/polkadot-launch && yarn && yarn composable
'''

[tasks.run-local-integration-tests]
workspace=false
script='''
# we cannot use toolchain setting as different parts of codebase require different compiler
cargo +stable-x86_64-unknown-linux-gnu test --package local-integration-tests --features local-integration-tests
'''
57 changes: 20 additions & 37 deletions docs/rpc.md → docs/custom-rpcs.md
Original file line number Diff line number Diff line change
Expand Up @@ -330,63 +330,46 @@ 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 */
import { /* any custom defined types that are needed for the RPC */ } from '@composable/types/interfaces';
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:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[package]
name = "integration-tests"
name = "local-integration-tests"
description="Local in memory(no OS handles opened) integrations tests via simulator. It may take time as it builds several runtimes as has direct dependnency on runtime configuration"
version = "0.1.0"
edition = "2021"

Expand Down Expand Up @@ -56,16 +57,16 @@ orml-traits = { git = "https://github.com/open-web3-stack/open-runtime-module-li
smallvec = "1.6.1"

# local modules
common = { path = "../runtime/common", default-features = false }
primitives = { path = "../runtime/primitives", default-features = false }
oracle = { package = "pallet-oracle", path = "../frame/oracle", default-features = false }
vault = { package = "pallet-vault", path = "../frame/vault", default-features = false }
currency-factory = { package = "pallet-currency-factory", path = "../frame/currency-factory", default-features = false }
composable-traits = { path = "../frame/composable-traits", default-features = false }
call-filter = { package = "pallet-call-filter", path = "../frame/call-filter", default-features = false }
assets-registry = { package = "pallet-assets-registry", path = "../frame/assets-registry", default-features = false, optional = true }
governance-registry = { package = "pallet-governance-registry", path = "../frame/governance-registry", default-features = false, optional = true }
assets = { package = "pallet-assets", path = "../frame/assets", default-features = false, optional = true }
common = { path = "../../runtime/common", default-features = false }
primitives = { path = "../../runtime/primitives", default-features = false }
oracle = { package = "pallet-oracle", path = "../../frame/oracle", default-features = false }
vault = { package = "pallet-vault", path = "../../frame/vault", default-features = false }
currency-factory = { package = "pallet-currency-factory", path = "../../frame/currency-factory", default-features = false }
composable-traits = { path = "../../frame/composable-traits", default-features = false }
call-filter = { package = "pallet-call-filter", path = "../../frame/call-filter", default-features = false }
assets-registry = { package = "pallet-assets-registry", path = "../../frame/assets-registry", default-features = false, optional = true }
governance-registry = { package = "pallet-governance-registry", path = "../../frame/governance-registry", default-features = false, optional = true }
assets = { package = "pallet-assets", path = "../../frame/assets", default-features = false, optional = true }

# Used for the node template's RPCs
system-rpc-runtime-api = { package = "frame-system-rpc-runtime-api", git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.16", default-features = false }
Expand Down Expand Up @@ -101,19 +102,20 @@ sp-io = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0


# added on top of runtime for emulation of network
paste = "1.0.5"
paste = "1.0.6"
polkadot-core-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.16", default-features = false }
xcm-emulator = { git = "https://github.com/shaunxw/xcm-simulator", rev = "a250ffc998bac4831c5692c591dee7bc13f3aead", default-features = false }
kusama-runtime = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.16", default-features = false }
polkadot-primitives = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.16", default-features = false }
polkadot-runtime-parachains = { git = "https://github.com/paritytech/polkadot", branch = "release-v0.9.16", default-features = false }
dali-runtime = { package = "dali-runtime", path = "../runtime/dali", default-features = false }
dali-runtime = { package = "dali-runtime", path = "../../runtime/dali", default-features = false }

[dev-dependencies]
env_logger = "0.9.0"

[features]
default = ["std", "develop"]
local-integration-tests = []
default = ["std", "develop", "local-integration-tests"]
std = [
"codec/std",
"sp-api/std",
Expand Down
Loading