From 7887813a807dff861ba31c9c2870a5271c6a0083 Mon Sep 17 00:00:00 2001 From: homura Date: Fri, 10 Jul 2020 19:28:31 +0800 Subject: [PATCH] test: update testcase with new sdk --- tests/e2e/multisig.ts | 15 +++-- tests/e2e/package.json | 10 ++-- tests/e2e/sdk.test.ts | 36 +++++------ tests/e2e/tsconfig.json | 3 + tests/e2e/utils.ts | 2 +- tests/e2e/yarn.lock | 129 ++++++++++++++++++++-------------------- 6 files changed, 102 insertions(+), 93 deletions(-) create mode 100644 tests/e2e/tsconfig.json diff --git a/tests/e2e/multisig.ts b/tests/e2e/multisig.ts index cb82905fa..e7e8fa350 100644 --- a/tests/e2e/multisig.ts +++ b/tests/e2e/multisig.ts @@ -1,5 +1,5 @@ -import { Address } from '@mutajs/types'; -import { createBindingClass, write, Write } from '@mutajs/service'; +import { Address } from '@mutadev/types'; +import { createServiceBindingClass, write, Write } from '@mutadev/service'; type u8 = number; type u32 = number; @@ -21,9 +21,12 @@ interface GenerateMultiSigAccountResponse { } export interface MultiSigServiceModel { - generate_account: Write; + generate_account: Write; } -export const MultiSigService = createBindingClass('multi_signature', { - generate_account: write(), -}); +export const MultiSigService = createServiceBindingClass({ + serviceName: 'multi_signature', + write: { + generate_account: write(), + } +}) diff --git a/tests/e2e/package.json b/tests/e2e/package.json index dea05f612..e6c3e7d55 100644 --- a/tests/e2e/package.json +++ b/tests/e2e/package.json @@ -10,15 +10,15 @@ "prettier": "prettier --write **/*.{js,ts,graphql}" }, "dependencies": { - "@mutajs/account": "^0.11.2-dev.0", - "@mutajs/client": "^0.11.2-dev.0", - "@mutajs/service": "^0.11.2-dev.0", - "@mutajs/utils": "^0.11.2-dev.0", + "@mutadev/account": "0.2.0-dev+pr315.0", + "@mutadev/client": "0.2.0-dev+pr315.0", + "@mutadev/@mutadev/muta-sdk": "0.2.0-dev+pr315.0", + "@mutadev/service": "0.2.0-dev+pr315.0", + "@mutadev/utils": "0.2.0-dev+pr315.0", "@types/node": "^14.0.14", "apollo-boost": "^0.4.4", "graphql": "^15.2.0", "graphql-tag": "^2.10.1", - "muta-sdk": "^0.11.2-dev.0", "node-fetch": "^2.6.0", "toml": "^3.0.0", "ts-node": "^8.3.0", diff --git a/tests/e2e/sdk.test.ts b/tests/e2e/sdk.test.ts index bf64b00bd..ae7362e13 100644 --- a/tests/e2e/sdk.test.ts +++ b/tests/e2e/sdk.test.ts @@ -1,12 +1,12 @@ -import { Account } from '@mutajs/account'; -import { AssetService } from '@mutajs/service' -import { toHex } from '@mutajs/utils'; -import { retry } from '@mutajs/client'; -import * as sdk from 'muta-sdk'; +import { Account } from '@mutadev/account'; +import { AssetService } from '@mutadev/service' +import { toHex } from '@mutadev/utils'; +import { retry } from '@mutadev/client'; +import * as sdk from '@mutadev/muta-sdk'; import { mutaClient } from './utils'; import { MultiSigService } from './multisig'; -describe("API test via muta-sdk-js", () => { +describe("API test via @mutadev/muta-sdk-js", () => { test("getLatestBlock", async () => { let current_height = await mutaClient.getLatestBlockHeight(); expect(current_height).toBeGreaterThan(0); @@ -36,13 +36,13 @@ describe("API test via muta-sdk-js", () => { "0xf56924db538e77bb5951eb5ff0d02b88983c49c45eea30e8ae3e7234b311436c"; const account = sdk.Muta.accountFromPrivateKey(from_pk); - const assetService = new AssetService(mutaClient, account.address, account); + const assetService = new AssetService(mutaClient, account); - const from_balance_before = await assetService.get_balance({ + const from_balance_before = await assetService.read.get_balance({ user: from_addr, asset_id: asset_id })!; - const to_balance_before = await assetService.get_balance({ + const to_balance_before = await assetService.read.get_balance({ user: to_addr, asset_id: asset_id, })!; @@ -50,18 +50,18 @@ describe("API test via muta-sdk-js", () => { // transfer expect(account.address).toBe(from_addr); - await assetService.transfer({ + await assetService.write.transfer({ asset_id: asset_id, to: to_addr, value: 0x01, }) // check result - let from_balance_after = await assetService.get_balance({ + let from_balance_after = await assetService.read.get_balance({ user: from_addr, asset_id: asset_id, })!; - const to_balance_after = await assetService.get_balance({ + const to_balance_after = await assetService.read.get_balance({ user: to_addr, asset_id: asset_id, })!; @@ -80,7 +80,7 @@ describe("API test via muta-sdk-js", () => { '0x2000000000000000000000000000000000000000000000000000000000000000', ); - const multiSigService = new MultiSigService(mutaClient, wangYe.address, wangYe); + const multiSigService = new MultiSigService(mutaClient, wangYe); const GenerateMultiSigAccountPayload = { owner: wangYe.address, @@ -88,7 +88,7 @@ describe("API test via muta-sdk-js", () => { threshold: 2, memo: 'welcome to BiYouCun' }; - const generated = await multiSigService.generate_account(GenerateMultiSigAccountPayload); + const generated = await multiSigService.write.generate_account(GenerateMultiSigAccountPayload); expect(Number(generated.response.response.code)).toBe(0); const multiSigAddress = generated.response.response.succeedData.address; @@ -111,15 +111,15 @@ describe("API test via muta-sdk-js", () => { expect(String(e)).toContain('CheckSig'); } - const bothSignedCreateAssetTx = qing.signMultiSigTransaction(signedCreateAssetTx); + const bothSignedCreateAssetTx = qing.signTransaction(signedCreateAssetTx); const txHash = await mutaClient.sendTransaction(bothSignedCreateAssetTx); const receipt = await retry(() => mutaClient.getReceipt(toHex(txHash))); expect(Number(receipt.response.response.code)).toBe(0); // MultiSig address balance - const asset = JSON.parse(receipt.response.response.succeedData); - const assetService = new AssetService(mutaClient, wangYe.address, wangYe); - const balance = await assetService.get_balance({ + const asset = JSON.parse(receipt.response.response.succeedData as string); + const assetService = new AssetService(mutaClient, wangYe); + const balance = await assetService.read.get_balance({ asset_id: asset.id, user: multiSigAddress, }); diff --git a/tests/e2e/tsconfig.json b/tests/e2e/tsconfig.json new file mode 100644 index 000000000..544b7b4dd --- /dev/null +++ b/tests/e2e/tsconfig.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/tests/e2e/utils.ts b/tests/e2e/utils.ts index f623adec6..efe84126f 100644 --- a/tests/e2e/utils.ts +++ b/tests/e2e/utils.ts @@ -3,7 +3,7 @@ import { createHttpLink } from "apollo-link-http"; import { InMemoryCache } from "apollo-cache-inmemory"; import ApolloClient from "apollo-client"; import { readFileSync } from "fs"; -import { Muta } from "muta-sdk"; +import { Muta } from "@mutadev/muta-sdk"; const toml = require("toml"); export const CHAIN_ID = diff --git a/tests/e2e/yarn.lock b/tests/e2e/yarn.lock index f483d4cd4..4ec08ca18 100644 --- a/tests/e2e/yarn.lock +++ b/tests/e2e/yarn.lock @@ -345,88 +345,104 @@ "@types/istanbul-reports" "^1.1.1" "@types/yargs" "^13.0.0" -"@mutajs/account@^0.11.2-dev.0": - version "0.11.2-dev.0" - resolved "https://registry.yarnpkg.com/@mutajs/account/-/account-0.11.2-dev.0.tgz#34d046817e7bad79188ebc0b03a9fe3125a22580" - integrity sha512-80/f97hbIqnaN1+inN6N3fJRfJkvxfzdl3ma2JDFAtMoghI5r6WmoPjX5t67f3yip6nl/FsJstay5C9Q4qJQTA== +"@mutadev/account@0.2.0-dev+pr315.0": + version "0.2.0-dev" + resolved "https://registry.yarnpkg.com/@mutadev/account/-/account-0.2.0-dev.tgz#3b8b26499305debf4b291ba06ea65296a815a3e7" + integrity sha512-iwSeQ4dK7NjIN07S5gkN2fgeu6w2UxJNRItezQ55mm66Lxu21bR33k4Kqr/YKo/34D+JX1UPdhtyzolbPFVCDA== dependencies: - "@mutajs/utils" "^0.11.2-dev.0" + "@mutadev/defaults" "0.2.0-dev+pr315.0" + "@mutadev/utils" "0.2.0-dev+pr315.0" -"@mutajs/client-raw@^0.11.2-dev.0": - version "0.11.2-dev.0" - resolved "https://registry.yarnpkg.com/@mutajs/client-raw/-/client-raw-0.11.2-dev.0.tgz#8aa820ab85fd8a4e639723ec0418e4e94a4ce6d6" - integrity sha512-M5bWbVMRcr89+GivV6MkrM4gJP96nifUXbu5RFMkk2THiezA/ESnsWnovQZAUs0nCT0Hx0RtcKhHW3dCNp8m4A== +"@mutadev/client-raw@0.2.0-dev+pr315.0": + version "0.2.0-dev" + resolved "https://registry.yarnpkg.com/@mutadev/client-raw/-/client-raw-0.2.0-dev.tgz#d7b66689f43f6f875c54bda75b073ee4876ac4f1" + integrity sha512-cWQbqwzAAJIONIRLwW5oVs5Zdy+QjpIDV1EYLqRDyeulbHItMb+Cc9S0aOD0iD/fGpfz9h8BmyX+8RWYV4AVUg== dependencies: graphql-request "^1.8.2" graphql-tag "^2.10.1" -"@mutajs/client@^0.11.2-dev.0": - version "0.11.2-dev.0" - resolved "https://registry.yarnpkg.com/@mutajs/client/-/client-0.11.2-dev.0.tgz#83f87ef8e95bcdabead64431cf05f8bb3c183573" - integrity sha512-czCq35wbpNY/WTeogzwJAxSVk7H3gdKoF9JFB0LtS/WPgkchNgRy/hjQafrFb0HolD/UMAtWjOVmIqrd6DAGoA== +"@mutadev/client@0.2.0-dev+pr315.0": + version "0.2.0-dev" + resolved "https://registry.yarnpkg.com/@mutadev/client/-/client-0.2.0-dev.tgz#ba1562b6298fffb4fdbf52e1ba85606073a736cb" + integrity sha512-NL0XKxcmuCaTr8XUl2oam37fV08go6SNpEOvJP+yvOfxp00kZ4Sqv1P/r/ZNJo+tRwfbk81QHl3tJ9ZZURPF5A== dependencies: - "@mutajs/client-raw" "^0.11.2-dev.0" - "@mutajs/defaults" "^0.11.2-dev.0" - "@mutajs/shared" "^0.11.2-dev.0" - "@mutajs/types" "^0.11.2-dev.0" - "@mutajs/utils" "^0.11.2-dev.0" + "@mutadev/client-raw" "0.2.0-dev+pr315.0" + "@mutadev/defaults" "0.2.0-dev+pr315.0" + "@mutadev/shared" "0.2.0-dev+pr315.0" + "@mutadev/types" "0.2.0-dev+pr315.0" + "@mutadev/utils" "0.2.0-dev+pr315.0" "@types/lodash" "^4.14.149" invariant "^2.2.4" lodash "^4.17.15" p-limit "^2.3.0" utility-types "^3.10.0" -"@mutajs/defaults@^0.11.2-dev.0": - version "0.11.2-dev.0" - resolved "https://registry.yarnpkg.com/@mutajs/defaults/-/defaults-0.11.2-dev.0.tgz#03b7f76b236e08992d09c7a32cb37598ac05a191" - integrity sha512-0YS1doMN7Ofr/13omaz7ykeRk4X5ey1GDyeJUbAC+qedT3sQkViTn+/2b9eO/tZ+R2IB4GJYXY5ryZBqZDD87A== +"@mutadev/defaults@0.2.0-dev+pr315.0": + version "0.2.0-dev" + resolved "https://registry.yarnpkg.com/@mutadev/defaults/-/defaults-0.2.0-dev.tgz#549e1504a12c4a9c7a4a6a76dcd6db79059a6805" + integrity sha512-wZgPUmknBOq0po7TZZKtHREYLXJvjokUoPFcdcqO0loLE2mNoFUm5VSBtUBNLh3nt1hm/m14uliTFUhp3+M/Mw== + +"@mutadev/@mutadev/muta-sdk@0.2.0-dev+pr315.0": + version "0.2.0-dev" + resolved "https://registry.yarnpkg.com/@mutadev/@mutadev/muta-sdk/-/@mutadev/muta-sdk-0.2.0-dev.tgz#b2f57a3f8a61b96c01edc32de14001ee98a753e7" + integrity sha512-+iQ0WO80VYlGg+sIvzwX4KDtvvsbhgedEMjVTq96iaY+AmfV/SEZiFT691cHP3MA7lRvjkKK0ZxnxGbcjsZr5w== + dependencies: + "@mutadev/account" "0.2.0-dev+pr315.0" + "@mutadev/client" "0.2.0-dev+pr315.0" + "@mutadev/defaults" "0.2.0-dev+pr315.0" + "@mutadev/shared" "0.2.0-dev+pr315.0" + "@mutadev/types" "0.2.0-dev+pr315.0" + "@mutadev/wallet" "0.2.0-dev+pr315.0" + utility-types "^3.10.0" -"@mutajs/service@^0.11.2-dev.0": - version "0.11.2-dev.0" - resolved "https://registry.yarnpkg.com/@mutajs/service/-/service-0.11.2-dev.0.tgz#425cae8ddb31b55d42974ff6ff447c4650064bd3" - integrity sha512-FbHcLtZtdslTbvB35XoJkuwel/D5iikB1nAgel75nCD6JZ54aB5YZIaO6p4GEqbMuxdJt/auttB6gH2lhFmIbw== +"@mutadev/service@0.2.0-dev+pr315.0": + version "0.2.0-dev" + resolved "https://registry.yarnpkg.com/@mutadev/service/-/service-0.2.0-dev.tgz#84e88ec1aa35be5a7defb4b391608b52f125c7f1" + integrity sha512-5C/dbM1OWFDpgQJrO1xUW+Eb3AHu1Q10o3IC05pZpPaZCP3iu3kdwrZ5ZQORLT72epEcUoFsoc8RWE+b2rGcbA== dependencies: - "@mutajs/account" "^0.11.2-dev.0" - "@mutajs/client" "^0.11.2-dev.0" - "@mutajs/shared" "^0.11.2-dev.0" - "@mutajs/types" "^0.11.2-dev.0" - "@mutajs/utils" "^0.11.2-dev.0" + "@mutadev/account" "0.2.0-dev+pr315.0" + "@mutadev/client" "0.2.0-dev+pr315.0" + "@mutadev/shared" "0.2.0-dev+pr315.0" + "@mutadev/types" "0.2.0-dev+pr315.0" + "@mutadev/utils" "0.2.0-dev+pr315.0" + lodash "^4.17.15" + utility-types "^3.10.0" -"@mutajs/shared@^0.11.2-dev.0": - version "0.11.2-dev.0" - resolved "https://registry.yarnpkg.com/@mutajs/shared/-/shared-0.11.2-dev.0.tgz#448fcf7476f1f616516b4fccf9d2fa316917a9f8" - integrity sha512-ltxkJFwexloR4vEfOwfPCwgJLn+kPMXP5S7MaYfsi3nfbzsz78HrpgTIBfGoe1zukRQOjH/PUp+m/wEX4orUTg== +"@mutadev/shared@0.2.0-dev+pr315.0": + version "0.2.0-dev" + resolved "https://registry.yarnpkg.com/@mutadev/shared/-/shared-0.2.0-dev.tgz#ef7177c0755d6b9bdd9ff2e897784dcf2dce7fcc" + integrity sha512-IuZoX6mPrddiPWETAe5utrDMJ4QAOY6/v6G+m7WX3oPzYZ/Loey+1D+ZCb2XLKjcmkYJ7l4RUwIq+DnxmPsHlA== dependencies: "@types/invariant" "^2.2.4" bignumber.js "^9.0.0" invariant "^2.2.4" -"@mutajs/types@^0.11.2-dev.0": - version "0.11.2-dev.0" - resolved "https://registry.yarnpkg.com/@mutajs/types/-/types-0.11.2-dev.0.tgz#bdffdf501b12b2ced2743d0fe3405e25a23c1209" - integrity sha512-g6g9grPy7jPhF6Ouu+th3wYJDtL6XVKm8iAHtDwSfBJIkJSzHJPGgSB9pv0cAGrKMWPsa/2owQsfsiOwQoLlwA== +"@mutadev/types@0.2.0-dev+pr315.0": + version "0.2.0-dev" + resolved "https://registry.yarnpkg.com/@mutadev/types/-/types-0.2.0-dev.tgz#9342877bdf78ae9a86a30f0798242ca47039c1cf" + integrity sha512-FVEW4Hy5OBa7r+06grARAjJvvkR/wXiS+YeJrjWA/NDsUqwmZ1nOcHMrD9ulUZq1sEJQsDElvjo9ZeTFFwz0Xw== dependencies: bignumber.js "^9.0.0" -"@mutajs/utils@^0.11.2-dev.0": - version "0.11.2-dev.0" - resolved "https://registry.yarnpkg.com/@mutajs/utils/-/utils-0.11.2-dev.0.tgz#a72715fb29f0063987f0bde83342963236e42e9a" - integrity sha512-jgrJVuVAtoEA+kVXAytIH+lCRWjE4FRh/IeINJ9BpIqhF+eycHmgHjVVk8iVaZQVYGzJXPYoyxy7bqg1rsjwMQ== +"@mutadev/utils@0.2.0-dev+pr315.0": + version "0.2.0-dev" + resolved "https://registry.yarnpkg.com/@mutadev/utils/-/utils-0.2.0-dev.tgz#9a89ca196a654cd194f251fa0b67ab0dfdf4484b" + integrity sha512-xY7K3Vz7mCporHA5hvsyoJOF0nOHRGUQ3UF70TlIkzQ4C4tPBSuIapDLZu8+tZfEPLxRIa/dYNd/tJMnIV4zhQ== dependencies: - "@mutajs/types" "^0.11.2-dev.0" + "@mutadev/types" "0.2.0-dev+pr315.0" json-bigint "^0.3.0" keccak "^3.0.0" randombytes "^2.1.0" rlp "^2.2.5" secp256k1 "^4.0.0" -"@mutajs/wallet@^0.11.2-dev.0": - version "0.11.2-dev.0" - resolved "https://registry.yarnpkg.com/@mutajs/wallet/-/wallet-0.11.2-dev.0.tgz#281b7dbd720a76df265ee5615afb5239f7895a52" - integrity sha512-6JTdkafqUKXBw0wEfHGYdIR+oDAZNTVGOpdi2Y8xd0C7tT5Z7sOVHGD69JcGUkE3QvCvFWpqOdSqt2CtB7P5pQ== +"@mutadev/wallet@0.2.0-dev+pr315.0": + version "0.2.0-dev" + resolved "https://registry.yarnpkg.com/@mutadev/wallet/-/wallet-0.2.0-dev.tgz#3fddedbef9db7d144d39d635c41b8f39de6bb957" + integrity sha512-/6m2nPfz/GhVPg9EeKz/LrHVvoGQREjrFCYXZ5N2fCa9J08W8oNy4CcTynZpaDnekt22veBCHDeG0GTs61R3lg== dependencies: - "@mutajs/account" "^0.11.2-dev.0" - "@mutajs/utils" "^0.11.2-dev.0" + "@mutadev/account" "0.2.0-dev+pr315.0" + "@mutadev/utils" "0.2.0-dev+pr315.0" bip39 "^3.0.2" hdkey "^1.1.1" @@ -2717,19 +2733,6 @@ ms@^2.1.1: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -muta-sdk@^0.11.2-dev.0: - version "0.11.2-dev.0" - resolved "https://registry.yarnpkg.com/muta-sdk/-/muta-sdk-0.11.2-dev.0.tgz#7f0dc8f721984685966c17e7c71bbe24e876d554" - integrity sha512-94NVoH2UEaOcXMvkALEnB2RCirvNBMGau5KkocfCrMCE0rAP9hq0WVyZAAgullWLH/+L3fjMcaKNGjtt3/pG9A== - dependencies: - "@mutajs/account" "^0.11.2-dev.0" - "@mutajs/client" "^0.11.2-dev.0" - "@mutajs/defaults" "^0.11.2-dev.0" - "@mutajs/shared" "^0.11.2-dev.0" - "@mutajs/types" "^0.11.2-dev.0" - "@mutajs/wallet" "^0.11.2-dev.0" - utility-types "^3.10.0" - nan@^2.12.1, nan@^2.14.0: version "2.14.1" resolved "https://registry.yarnpkg.com/nan/-/nan-2.14.1.tgz#d7be34dfa3105b91494c3147089315eff8874b01"