suidouble 0.0.10 → 0.0.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/SuiTestScenario.js
CHANGED
|
@@ -21,6 +21,10 @@ class SuiTestScenario extends SuiCommonMethods {
|
|
|
21
21
|
this._publishedPackageId = null;
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
get currentAs() {
|
|
25
|
+
return this._currentAs;
|
|
26
|
+
}
|
|
27
|
+
|
|
24
28
|
/**
|
|
25
29
|
* Start local test validator and set up `as` as owner of package deploy transaction.
|
|
26
30
|
* Package will be deployed with method `init`, as we try to mimic Sui Move's test_scenario
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "suidouble",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.11",
|
|
4
4
|
"description": "Set of provider, package and object classes for javascript representation of Sui Move smart contracts. Use same code for publishing, upgrading, integration testing, interaction with smart contracts and integration in browser web3 dapps",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const t = require('tap');
|
|
4
|
+
const { test } = t;
|
|
5
|
+
const path = require('path');
|
|
6
|
+
|
|
7
|
+
const { SuiTestScenario } = require('..');
|
|
8
|
+
|
|
9
|
+
let testScenario = null;
|
|
10
|
+
|
|
11
|
+
test('initialization', async t => {
|
|
12
|
+
testScenario = new SuiTestScenario({
|
|
13
|
+
path: path.join(__dirname, './test_move_contracts/suidouble_chat/'),
|
|
14
|
+
debug: false,
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
await testScenario.begin('admin');
|
|
18
|
+
await testScenario.init();
|
|
19
|
+
|
|
20
|
+
t.equal(testScenario.currentAs, 'admin');
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
test('checking takeShared', async t => {
|
|
24
|
+
t.plan(4);
|
|
25
|
+
|
|
26
|
+
await testScenario.nextTx('admin', async()=>{
|
|
27
|
+
const chatShop = testScenario.takeShared('ChatShop');
|
|
28
|
+
|
|
29
|
+
t.ok(chatShop.address); // there should be some address
|
|
30
|
+
t.ok(`${chatShop.address}`.indexOf('0x') === 0); // adress is string starting with '0x'
|
|
31
|
+
|
|
32
|
+
await testScenario.moveCall('suidouble_chat', 'post', [chatShop.address, 'posting a message', 'metadata']);
|
|
33
|
+
const chatTopMessage = testScenario.takeShared('ChatTopMessage');
|
|
34
|
+
|
|
35
|
+
t.ok(chatTopMessage.address); // there should be some address
|
|
36
|
+
t.ok(`${chatTopMessage.address}`.indexOf('0x') === 0); // adress is string starting with '0x'
|
|
37
|
+
});
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
test('checking takeOwned', async t => {
|
|
41
|
+
t.plan(3);
|
|
42
|
+
|
|
43
|
+
await testScenario.nextTx('somebody', async()=>{
|
|
44
|
+
const chatTopMessage = testScenario.takeShared('ChatTopMessage');
|
|
45
|
+
t.ok(chatTopMessage.address); // there should be some address
|
|
46
|
+
|
|
47
|
+
await testScenario.moveCall('suidouble_chat', 'reply', [chatTopMessage.address, 'posting a response', 'metadata']);
|
|
48
|
+
const chatResponse = testScenario.takeFromSender('ChatResponse');
|
|
49
|
+
|
|
50
|
+
t.ok(chatResponse.address); // there should be some address
|
|
51
|
+
t.ok(`${chatResponse.address}`.indexOf('0x') === 0); // adress is string starting with '0x'
|
|
52
|
+
});
|
|
53
|
+
})
|
|
54
|
+
|
|
55
|
+
test('finishing the test scenario', async t => {
|
|
56
|
+
await testScenario.end();
|
|
57
|
+
});
|