Skip to content

Commit da6c8c3

Browse files
authored
Merge pull request #271 from Dapiguabc/use-new-lamden-js
set network version tests pass
2 parents 3b19992 + cb6d694 commit da6c8c3

28 files changed

+1142
-136
lines changed

package-lock.json

+30-30
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+6-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "lamden-wallet",
3-
"version": "2.3.1",
3+
"version": "2.3.2",
44
"description": "A secure wallet for making transactions on the Lamden blockchain.",
55
"author": "Jeff Scott <[email protected]>",
66
"license": "",
@@ -30,6 +30,10 @@
3030
"test-backup-view-accounts": "mocha --timeout 60000 selenium/tests/ui/backup/backup-view-accounts.js",
3131
"test-misc": "mocha --timeout 60000 selenium/tests/ui/misc/*.js",
3232
"test-misc-network": "mocha --timeout 60000 selenium/tests/ui/misc/network.js",
33+
"test-dapps-wallet-connect-v2": "mocha --timeout 60000 selenium/tests/dapp/content_lamdenWalletConnect_v2.js",
34+
"test-dapps-get-info-v2": "mocha --timeout 60000 selenium/tests/dapp/content_lamdenWalletGetInfo_v2.js",
35+
"test-dapps-sendtx-v2": "mocha --timeout 60000 selenium/tests/dapp/content_lamdenWalletSendTx_v2.js",
36+
"test-dapps-sendx-backtoback-v2": "mocha --timeout 60000 selenium/tests/dapp/content_landenWalletSendTxBacktoBack_v2.js",
3337
"dev": "node utils/webserver.js"
3438
},
3539
"repository": {
@@ -38,7 +42,7 @@
3842
},
3943
"devDependencies": {
4044
"@babel/runtime": "^7.12.0",
41-
"chromedriver": "^106.0.1",
45+
"chromedriver": "^107.0.3",
4246
"clean-webpack-plugin": "^1.0.0",
4347
"copy-webpack-plugin": "^10.2.4",
4448
"css-loader": "2.1.0",

selenium/config/chrome_config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
22
"backup": "mcmjfpfhmepgncgcefnfnlbhplckagnf",
3-
"walletExtentionID": "milbhnchmaidmgioekemioacdgkojndh"
3+
"walletExtentionID": "mcmjfpfhmepgncgcefnfnlbhplckagnf"
44
}

selenium/config/config.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ const config = {
4949
walletExtentionID: chromeConfig.walletExtentionID,
5050
port: 5656,
5151
testnetMasternode: "https://testnet-master-1.lamden.io:443",
52-
testnetBlockService: "http://165.227.181.34:3535"
52+
testnetBlockService: "http://165.227.181.34:3535",
53+
testnetBlockService_v2: "https://testnet-v2-bs-lon.lamden.io"
5354
}
5455
module.exports = config

selenium/fixtures/dappsInfo_v2.json

+68
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
{
2+
"basicConnectionInfo": {
3+
"appName": "Dapp Testing",
4+
"version": "1.0.0",
5+
"contractName": "con_wallet_testing",
6+
"networkType": "testnet",
7+
"networkVersion": 2,
8+
"logo": "/images/logo.png"
9+
},
10+
"charmsInfo": [{
11+
"formatAs": "string",
12+
"iconPath": "/images/charm.png",
13+
"variableName": "yourState",
14+
"key": "wallet_testing",
15+
"name": "Testing Value"
16+
}],
17+
"updatedConnectionInfo_basic": {
18+
"appName": "Dapp Testing Updating",
19+
"version": "1.0.1",
20+
"contractName": "con_wallet_testing",
21+
"networkType": "testnet",
22+
"logo": "/images/logo2.png",
23+
"networkVersion": 2,
24+
"backgound": "/images/background2.png"
25+
},
26+
"updatedConnectionInfo_smartcontract": {
27+
"appName": "Dapp Testing Updating",
28+
"version": "1.0.2",
29+
"contractName": "con_wallet_testing_2",
30+
"networkType": "testnet",
31+
"logo": "/images/logo2.png",
32+
"networkVersion": 2,
33+
"backgound": "/images/background2.png"
34+
},
35+
"background": "/images/background.png",
36+
"basicTransactionInfo":{
37+
"methodName": "set_value",
38+
"networkType": "testnet",
39+
"networkVersion": 2,
40+
"kwargs":{
41+
"key_name": "con_wallet_testing",
42+
"key_value" : ""
43+
},
44+
"stampLimit": 30
45+
},
46+
"approvalTransaction": {
47+
"contractName": "currency",
48+
"methodName": "approve",
49+
"networkType": "testnet",
50+
"networkVersion": 2,
51+
"kwargs":{
52+
"to": "con_wallet_testing",
53+
"amount" : 1
54+
},
55+
"stampLimit": 20
56+
},
57+
"nonStandardTransactionInfo":{
58+
"contractName": "con_wallet_testing_2",
59+
"methodName": "set_value",
60+
"networkType": "testnet",
61+
"networkVersion": 2,
62+
"kwargs":{
63+
"key_name": "con_wallet_testing_2",
64+
"key_value" : ""
65+
},
66+
"stampLimit": 20
67+
}
68+
}

selenium/helpers/helpers.js

+14-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const assert = require('assert');
99
const { CryptoJS } = nodeCryptoJs;
1010
const mnemonicWords = require("../fixtures/mnemonic.json")
1111

12-
const { testnetMasternode, testnetBlockService } = config;
12+
const { testnetMasternode, testnetBlockService, testnetBlockService_v2} = config;
1313

1414
const wait_sync = (seconds) => {
1515
Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, seconds);
@@ -151,6 +151,13 @@ const changeToTestnet = async (driver) => {
151151
await sleep(2000, true)
152152
}
153153

154+
const changeToTestnetV2 = async (driver) => {
155+
await driver.wait(until.elementLocated(By.id('nav-network-currently-selected')), 5000).click();
156+
let navNetwork = await driver.wait(until.elementLocated(By.id("select-option-2")), 5000);
157+
navNetwork.click()
158+
await sleep(2000, true)
159+
}
160+
154161
const setAsTrustedDapp = async (driver) => {
155162
await sleep(500, true)
156163
await driver.findElement(By.id("dapp-connections")).click()
@@ -364,16 +371,17 @@ const getAccountBalance = (vk) => {
364371
})
365372
}
366373

367-
const getApprovalAmount = (sender, to) => {
374+
const getApprovalAmount = (sender, to, version = 1) => {
368375
return new Promise(resolver => {
369376
const resolveRequest = (data) => {
370377
if (typeof data.value === 'undefined') return resolver(0)
371378
if (!data.value) return resolver(0)
372379
if (data.value.__fixed__) return resolver(parseInt(data.value.__fixed__))
373380
else return resolver(parseInt(data.value))
374381
}
375-
console.log(`${testnetBlockService}/current/one/currency/balances/${sender}:${to}`)
376-
makeHttpRequest(`${testnetBlockService}/current/one/currency/balances/${sender}:${to}`, resolveRequest)
382+
let api = version === 2 ? testnetBlockService_v2 : testnetBlockService
383+
console.log(`${api}/current/one/currency/balances/${sender}:${to}`)
384+
makeHttpRequest(`${api}/current/one/currency/balances/${sender}:${to}`, resolveRequest)
377385
})
378386
}
379387

@@ -545,5 +553,6 @@ module.exports = {
545553
clearNetwork,
546554
fillNetworkForm,
547555
gotoBackup,
548-
createUID
556+
createUID,
557+
changeToTestnetV2
549558
}

selenium/tests/dapp/content_lamdenWalletConnect.js

+16-16
Original file line numberDiff line numberDiff line change
@@ -319,10 +319,10 @@ describe('Content Script - Testing Dapp Connection API', function () {
319319

320320
assert.equal(response.errors, null);
321321
assert.equal(response.wallets.length, 1);
322-
assert.equal(response.approvals['testnet'].contractName, connection.contractName);
323-
assert.equal(response.approvals['testnet'].version, connection.version);
324-
assert.equal(response.approvals['testnet'].trustedApp, true);
325-
assert.equal(response.approvals['testnet'].charms.length, 1);
322+
assert.equal(response.approvals['V1|testnet'].contractName, connection.contractName);
323+
assert.equal(response.approvals['V1|testnet'].version, connection.version);
324+
assert.equal(response.approvals['V1|testnet'].trustedApp, true);
325+
assert.equal(response.approvals['V1|testnet'].charms.length, 1);
326326
});
327327
it('POPUP: Can Update connection info if version is greater', async function() {
328328
let connection = helpers.getInstance(dappsInfo.updatedConnectionInfo_basic)
@@ -334,10 +334,10 @@ describe('Content Script - Testing Dapp Connection API', function () {
334334

335335
assert.equal(response.errors, null);
336336
assert.equal(response.wallets.length, 1);
337-
assert.equal(response.approvals['testnet'].contractName, connection.contractName);
338-
assert.equal(response.approvals['testnet'].version, dappsInfo.updatedConnectionInfo_basic.version);
339-
assert.equal(response.approvals['testnet'].trustedApp, true);
340-
assert.equal(response.approvals['testnet'].charms.length, 2);
337+
assert.equal(response.approvals['V1|testnet'].contractName, connection.contractName);
338+
assert.equal(response.approvals['V1|testnet'].version, dappsInfo.updatedConnectionInfo_basic.version);
339+
assert.equal(response.approvals['V1|testnet'].trustedApp, true);
340+
assert.equal(response.approvals['V1|testnet'].charms.length, 2);
341341
});
342342
it('POPUP: Can Update smart contract after reapproval if version is greater', async function() {
343343
let connection = helpers.getInstance(dappsInfo.updatedConnectionInfo_smartcontract)
@@ -350,10 +350,10 @@ describe('Content Script - Testing Dapp Connection API', function () {
350350

351351
assert.equal(response.errors, null);
352352
assert.equal(response.wallets.length, 1);
353-
assert.equal(response.approvals['testnet'].contractName, connection.contractName);
354-
assert.equal(response.approvals['testnet'].version, dappsInfo.updatedConnectionInfo_smartcontract.version);
355-
assert.equal(response.approvals['testnet'].trustedApp, true);
356-
assert.equal(typeof response.approvals['testnet'].charms === 'undefined', true);
353+
assert.equal(response.approvals['V1|testnet'].contractName, connection.contractName);
354+
assert.equal(response.approvals['V1|testnet'].version, dappsInfo.updatedConnectionInfo_smartcontract.version);
355+
assert.equal(response.approvals['V1|testnet'].trustedApp, true);
356+
assert.equal(typeof response.approvals['V1|testnet'].charms === 'undefined', true);
357357
});
358358
it('Does nothing if a smart contract update is sent with an equal or lower version', async function() {
359359
let connection = helpers.getInstance(dappsInfo.updatedConnectionInfo_basic)
@@ -371,10 +371,10 @@ describe('Content Script - Testing Dapp Connection API', function () {
371371

372372
assert.equal(response.errors, null);
373373
assert.equal(response.wallets.length, 1);
374-
assert.equal(response.approvals['testnet'].contractName, dappsInfo.updatedConnectionInfo_smartcontract.contractName);
375-
assert.equal(response.approvals['testnet'].version, dappsInfo.updatedConnectionInfo_smartcontract.version);
376-
assert.equal(response.approvals['testnet'].trustedApp, true);
377-
assert.equal(typeof response.approvals['testnet'].charms === 'undefined', true);
374+
assert.equal(response.approvals['V1|testnet'].contractName, dappsInfo.updatedConnectionInfo_smartcontract.contractName);
375+
assert.equal(response.approvals['V1|testnet'].version, dappsInfo.updatedConnectionInfo_smartcontract.version);
376+
assert.equal(response.approvals['V1|testnet'].trustedApp, true);
377+
assert.equal(typeof response.approvals['V1|testnet'].charms === 'undefined', true);
378378
});
379379
})
380380
})

0 commit comments

Comments
 (0)