|
@@ -27,9 +27,25 @@ let owner_datawriter: Datawriter
|
27
|
27
|
|
28
|
28
|
|
29
|
29
|
const setup = async () => {
|
30
|
|
-
|
31
|
|
- [ownerWallet, listeningWallet, userWallet, drainWallet] = await Promise.all([makeTestnetWallet(), makeTestnetWallet(), makeTestnetWallet(), makeTestnetWallet()])
|
32
|
|
-
|
|
30
|
+ // [ownerWallet, listeningWallet, userWallet, drainWallet] = await Promise.all([makeTestnetWallet(),makeTestnetWallet(),makeTestnetWallet(),makeTestnetWallet()])
|
|
31
|
+ [ownerWallet, listeningWallet, userWallet, drainWallet] = [
|
|
32
|
+ {
|
|
33
|
+ secret: 'sEd7tPDHFk3w7ABSaCPYi12iwucMQLt',
|
|
34
|
+ address: 'rDML7QhJeVxZTwsjPtm4iyLUJTCzzuppMo'
|
|
35
|
+ },
|
|
36
|
+ {
|
|
37
|
+ secret: 'sEdSgbyouvLM26vq2F2XthfKGWndP72',
|
|
38
|
+ address: 'rPvwbb4JHncG9rKVrYATJw6HRixR69wgjg'
|
|
39
|
+ },
|
|
40
|
+ {
|
|
41
|
+ secret: 'sEd7c1Y8JwWyA2owbchMWnuzAhB3ypY',
|
|
42
|
+ address: 'rwuuWdyxwf3o78Ce2DAZrYCQ12SSawTp6M'
|
|
43
|
+ },
|
|
44
|
+ {
|
|
45
|
+ secret: 'sEdScantwGA5gYe4atKPbG5bsriURpf',
|
|
46
|
+ address: 'rDiwSioTRyV29rNk2FskxqFtMaRsmWvS7C'
|
|
47
|
+ }
|
|
48
|
+ ]
|
33
|
49
|
owner_datawriter = new Datawriter({
|
34
|
50
|
receiveAddress: drainWallet.address,
|
35
|
51
|
sendWallet: ownerWallet,
|
|
@@ -129,7 +145,7 @@ const setup = async () => {
|
129
|
145
|
describe('RJSVM basic functions', () => {
|
130
|
146
|
|
131
|
147
|
before(async function () {
|
132
|
|
- this.timeout(10000)
|
|
148
|
+ this.timeout(100000)
|
133
|
149
|
await setup()
|
134
|
150
|
})
|
135
|
151
|
|
|
@@ -138,13 +154,15 @@ describe('RJSVM basic functions', () => {
|
138
|
154
|
})
|
139
|
155
|
|
140
|
156
|
it('Env contains the payload carrying transaction', function (done) {
|
141
|
|
- this.timeout(30000)
|
|
157
|
+ this.timeout(45000)
|
142
|
158
|
|
|
159
|
+ console.log("Making wallet...")
|
143
|
160
|
makeTestnetWallet().then(async testWallet => {
|
|
161
|
+ console.log(testWallet)
|
144
|
162
|
//create a mock RJSVM
|
145
|
163
|
abstract class RJSVM_Base
|
146
|
|
- extends RJSVM<undefined, { testEndpoint: () => void }>
|
147
|
|
- implements RJSVM_Interface<RJSVM_Base> {
|
|
164
|
+ extends RJSVM<undefined, { testEndpoint: () => void }>
|
|
165
|
+ implements RJSVM_Interface<RJSVM_Base> {
|
148
|
166
|
owner = ownerWallet.address
|
149
|
167
|
state = undefined
|
150
|
168
|
}
|
|
@@ -153,17 +171,12 @@ describe('RJSVM basic functions', () => {
|
153
|
171
|
const RJSVM_Contract: RJSVM_Implementations<RJSVM_Base> = {
|
154
|
172
|
testEndpoint: {
|
155
|
173
|
implementation: function (env) {
|
156
|
|
-
|
157
|
174
|
expect(env.Account).to.be.equal(userWallet.address)
|
158
|
175
|
expect(env.Amount).to.be.equal('1')
|
159
|
176
|
expect(env.Destination).to.be.equal(testWallet.address)
|
160
|
177
|
expect(Number(env.Fee)).to.be.greaterThanOrEqual(10)
|
161
|
178
|
expect(env.LastLedgerSequence).to.be.a('number')
|
162
|
|
-
|
163
|
179
|
expect(env.Memos).to.be.an('Array')
|
164
|
|
- const memo = JSON.parse(DataParser.hex_to_ascii(env.Memos[0].Memo.MemoData))
|
165
|
|
- expect(memo.endpoint).to.be.equal('testEndpoint')
|
166
|
|
-
|
167
|
180
|
expect(env.Sequence).to.be.a('number')
|
168
|
181
|
expect(env.SigningPubKey).to.be.a('string')
|
169
|
182
|
expect(env.TransactionType).to.be.equal('Payment')
|
|
@@ -172,7 +185,6 @@ describe('RJSVM basic functions', () => {
|
172
|
185
|
expect(env.hash).to.be.a('string')
|
173
|
186
|
expect(env.inLedger).to.be.a('number')
|
174
|
187
|
expect(env.ledger_index).to.be.a('number')
|
175
|
|
-
|
176
|
188
|
runnable.disconnect()
|
177
|
189
|
done()
|
178
|
190
|
},
|
|
@@ -182,7 +194,7 @@ describe('RJSVM basic functions', () => {
|
182
|
194
|
}
|
183
|
195
|
|
184
|
196
|
const Rjsvm = RJSVM_Builder.from(RJSVM_Base, RJSVM_Contract)
|
185
|
|
- const runnable = new Rjsvm({listeningAddress: testWallet.address,rippleNode: xrpNode})
|
|
197
|
+ const runnable = new Rjsvm({ listeningAddress: testWallet.address, rippleNode: xrpNode })
|
186
|
198
|
await runnable.connect()
|
187
|
199
|
|
188
|
200
|
const dw = new Datawriter({
|
|
@@ -197,7 +209,7 @@ describe('RJSVM basic functions', () => {
|
197
|
209
|
})
|
198
|
210
|
|
199
|
211
|
it('Called endpoint triggers in RJSVM', function (done) {
|
200
|
|
- this.timeout(30000)
|
|
212
|
+ this.timeout(45000)
|
201
|
213
|
|
202
|
214
|
const data = { title: "1", body: "2", from: "3" };
|
203
|
215
|
rjsvm.once('submit', (payload) => {
|
|
@@ -209,7 +221,7 @@ describe('RJSVM basic functions', () => {
|
209
|
221
|
})
|
210
|
222
|
|
211
|
223
|
it('Calling an endpoint with insufficient fee fails', function (done) {
|
212
|
|
- this.timeout(30000)
|
|
224
|
+ this.timeout(45000)
|
213
|
225
|
|
214
|
226
|
const data = { title: "f", body: "f", from: "f" };
|
215
|
227
|
rjsvm.once('error', (err) => {
|
|
@@ -220,7 +232,7 @@ describe('RJSVM basic functions', () => {
|
220
|
232
|
})
|
221
|
233
|
|
222
|
234
|
it('Restricted endpoint can be called by owner', function (done) {
|
223
|
|
- this.timeout(30000)
|
|
235
|
+ this.timeout(45000)
|
224
|
236
|
|
225
|
237
|
const data = { title: "11", body: "22", from: "33" };
|
226
|
238
|
rjsvm.once('restricted', (payload) => {
|
|
@@ -233,7 +245,7 @@ describe('RJSVM basic functions', () => {
|
233
|
245
|
|
234
|
246
|
|
235
|
247
|
it('Restricted endpoint cannot be called by non-owner', function (done) {
|
236
|
|
- this.timeout(30000)
|
|
248
|
+ this.timeout(45000)
|
237
|
249
|
|
238
|
250
|
const data = { title: "e", body: "e", from: "e" };
|
239
|
251
|
rjsvm.once('error', (err) => {
|