Skip to content

Commit

Permalink
CU-3jtkmm5 - Refine downloadFileByHiveUrl() to fit wrong params string.
Browse files Browse the repository at this point in the history
  • Loading branch information
fred-yu-2013 authored and stiartsly committed Sep 22, 2022
1 parent a3b7387 commit b52f376
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@elastosfoundation/hive-js-sdk",
"version": "2.8.1",
"version": "2.9.2",
"description": "Elastos Hive JS SDK",
"exports": {
"node": "./dist/hive.js",
Expand Down
3 changes: 2 additions & 1 deletion src/service/scripting/scriptingservice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,8 @@ export class ScriptingService extends RestService {
targetUsrDid: dids[0],
targetAppDid: dids[1],
scriptName: values[0],
params: values[1]
// params: values[1]
params: '{}' // INFO: compatible with wrong params string, such as {empty:0} [miss "" around empty]
}
}

Expand Down
13 changes: 10 additions & 3 deletions tests/src/scripting/scriptrunner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,12 @@ describe("test scripting runner function", () => {
await downloadFileByHiveUrl(true);
});

test("testDownloadFileByHiveUrl on mainnet", async () => {
test("testDownloadFileByHiveUrlWithReal", async () => {
const checkHiveUrl = async (url) => {
const buffer = await scriptRunner.downloadFileByHiveUrl(url);
expect(buffer).not.toBeNull();
}

// INFO: only for EE to get the avatar image from user did related vault.
let hiveUrl = null;
if (testData.isTestnet()) {
Expand All @@ -240,8 +245,10 @@ describe("test scripting runner function", () => {
// avatar is on hive1 mainnet node.
hiveUrl = 'hive://did:elastos:iabbGwqUN18F6YxkndmZCiHpRPFsQF1imT@did:elastos:ig1nqyyJhwTctdLyDFbZomSbZSjyMN1uor/getMainIdentityAvatar1627717470347?params={"empty":0}';
}
const buffer = await scriptRunner.downloadFileByHiveUrl(hiveUrl);
expect(buffer).not.toBeNull();
await checkHiveUrl(hiveUrl);
// compatible check.
hiveUrl = hiveUrl.replace('{"empty":0}', '{empty:0}');
await checkHiveUrl(hiveUrl);
});

test.skip("testDownloadWithInvalidTransactionId", async () => {
Expand Down

0 comments on commit b52f376

Please sign in to comment.