Skip to content

Commit

Permalink
manual rpc test works (#566)
Browse files Browse the repository at this point in the history
* manual rpc test works

Signed-off-by: Shumo Chu <[email protected]>

* clean up

Signed-off-by: Shumo Chu <[email protected]>
  • Loading branch information
stechu authored May 26, 2022
1 parent 67bbfbc commit 14672e4
Show file tree
Hide file tree
Showing 6 changed files with 865 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pallets/manta-pay/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use sp_runtime::{generic::BlockId, traits::Block};
pub trait PullApi {
/// Returns the update required to be synchronized with the ledger starting from
/// `checkpoint`.
#[rpc(name = "manta_pay_pull")]
#[rpc(name = "mantaPay_pull")]
fn pull(&self, checkpoint: Checkpoint) -> Result<PullResponse>;
}

Expand Down
7 changes: 7 additions & 0 deletions tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Functional Tests for Manta
==========================

Get data from `mantaPay_pull` rpc methods:
```bash
yarn ts-node index.ts
```
42 changes: 42 additions & 0 deletions tests/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { ApiPromise, WsProvider } from '@polkadot/api';

// Construct
const wsProvider = new WsProvider('ws://127.0.0.1:9800');
async function main(){
const api = await ApiPromise.create({
provider: wsProvider,
types: {
Checkpoint: {
receiver_index: '[u64; 256]',
sender_index: 'u64'
},
EncryptedNote: {
ephemeral_public_key: '[u8; 32]',
ciphertext: '[u8; 68]'
},
PullResponse: {
should_continue: 'bool',
checkpoint: 'Checkpoint',
receivers: 'Vec<([u8; 32], EncryptedNote)>',
senders: 'Vec<[u8; 32]>',
}
},
rpc: {
mantapay: {
pull: {
description: 'pull from mantaPay',
params: [
{
name: 'checkpoint',
type: 'Checkpoint'
}
],
type: 'PullResponse'
}
}
}});
const junk = await (api.rpc as any).mantapay.pull({receiver_index: new Array(256).fill(0), sender_index: 0});
console.log(junk);
}

main().catch(console.error).finally(() => process.exit());
19 changes: 19 additions & 0 deletions tests/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"name": "manta-tests",
"version": "1.0.0",
"description": "Functional Tests for Manta",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@polkadot/api": "^7.10.1",
"@polkadot/types": "^7.10.1",
"@types/yargs": "^17.0.0",
"ts-node": "^10.8.0",
"typescript": "4.6.4"
}
}
10 changes: 10 additions & 0 deletions tests/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"compilerOptions": {
"target": "es2016",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"skipLibCheck": true
}
}
Loading

0 comments on commit 14672e4

Please sign in to comment.