Skip to content

Commit 86df069

Browse files
committed
Added e2e test for accountNames and MoasicNames
1 parent c8ffc7c commit 86df069

File tree

2 files changed

+168
-19
lines changed

2 files changed

+168
-19
lines changed

e2e/infrastructure/AccountHttp.spec.ts

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ describe('AccountHttp', () => {
121121
});
122122
});
123123

124-
describe('Setup test AddressAlias', () => {
124+
describe('Setup test NamespaceId', () => {
125125
let listener: Listener;
126126
before (() => {
127127
listener = new Listener(config.apiUrl);
@@ -130,17 +130,16 @@ describe('AccountHttp', () => {
130130
after(() => {
131131
return listener.close();
132132
});
133-
134-
it('Announce addressAliasTransaction', (done) => {
135-
const addressAliasTransaction = AddressAliasTransaction.create(
133+
it('Announce RegisterNamespaceTransaction', (done) => {
134+
const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000);
135+
const registerNamespaceTransaction = RegisterNamespaceTransaction.createRootNamespace(
136136
Deadline.create(),
137-
AliasActionType.Link,
138-
namespaceId,
139-
account.address,
137+
namespaceName,
138+
UInt64.fromUint(1000),
140139
NetworkType.MIJIN_TEST,
141140
);
142-
const signedTransaction = addressAliasTransaction.signWith(account);
143-
141+
namespaceId = new NamespaceId(namespaceName);
142+
const signedTransaction = registerNamespaceTransaction.signWith(account);
144143
listener.confirmed(account.address).subscribe((transaction) => {
145144
done();
146145
});
@@ -153,7 +152,7 @@ describe('AccountHttp', () => {
153152
});
154153
});
155154

156-
describe('Setup test NamespaceId', () => {
155+
describe('Setup test AddressAlias', () => {
157156
let listener: Listener;
158157
before (() => {
159158
listener = new Listener(config.apiUrl);
@@ -162,16 +161,17 @@ describe('AccountHttp', () => {
162161
after(() => {
163162
return listener.close();
164163
});
165-
it('Announce RegisterNamespaceTransaction', (done) => {
166-
const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000);
167-
const registerNamespaceTransaction = RegisterNamespaceTransaction.createRootNamespace(
164+
165+
it('Announce addressAliasTransaction', (done) => {
166+
const addressAliasTransaction = AddressAliasTransaction.create(
168167
Deadline.create(),
169-
namespaceName,
170-
UInt64.fromUint(1000),
168+
AliasActionType.Link,
169+
namespaceId,
170+
account.address,
171171
NetworkType.MIJIN_TEST,
172172
);
173-
namespaceId = new NamespaceId(namespaceName);
174-
const signedTransaction = registerNamespaceTransaction.signWith(account);
173+
const signedTransaction = addressAliasTransaction.signWith(account);
174+
175175
listener.confirmed(account.address).subscribe((transaction) => {
176176
done();
177177
});
@@ -183,7 +183,6 @@ describe('AccountHttp', () => {
183183
transactionHttp.announce(signedTransaction);
184184
});
185185
});
186-
187186
describe('Setup Test AccountAddressProperty', () => {
188187
let listener: Listener;
189188
before (() => {
@@ -447,6 +446,37 @@ describe('AccountHttp', () => {
447446
});
448447
});
449448

449+
describe('Remove test AddressAlias', () => {
450+
let listener: Listener;
451+
before (() => {
452+
listener = new Listener(config.apiUrl);
453+
return listener.open();
454+
});
455+
after(() => {
456+
return listener.close();
457+
});
458+
459+
it('Announce addressAliasTransaction', (done) => {
460+
const addressAliasTransaction = AddressAliasTransaction.create(
461+
Deadline.create(),
462+
AliasActionType.Unlink,
463+
namespaceId,
464+
account.address,
465+
NetworkType.MIJIN_TEST,
466+
);
467+
const signedTransaction = addressAliasTransaction.signWith(account);
468+
469+
listener.confirmed(account.address).subscribe((transaction) => {
470+
done();
471+
});
472+
listener.status(account.address).subscribe((error) => {
473+
console.log('Error:', error);
474+
assert(false);
475+
done();
476+
});
477+
transactionHttp.announce(signedTransaction);
478+
});
479+
});
450480
describe('Restore test multisig Accounts', () => {
451481
let listener: Listener;
452482
before (() => {

e2e/infrastructure/MosaicHttp.spec.ts

Lines changed: 120 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
* See the License for the specific language governing permissions and
1414
* limitations under the License.
1515
*/
16-
import {expect} from 'chai';
16+
import {expect, assert} from 'chai';
1717
import { Listener, TransactionHttp } from '../../src/infrastructure/infrastructure';
1818
import {MosaicHttp} from '../../src/infrastructure/MosaicHttp';
1919
import { Account } from '../../src/model/account/Account';
@@ -24,12 +24,17 @@ import { MosaicProperties } from '../../src/model/mosaic/MosaicProperties';
2424
import {NamespaceId} from '../../src/model/namespace/NamespaceId';
2525
import { Deadline } from '../../src/model/transaction/Deadline';
2626
import { MosaicDefinitionTransaction } from '../../src/model/transaction/MosaicDefinitionTransaction';
27+
import { RegisterNamespaceTransaction } from '../../src/model/transaction/RegisterNamespaceTransaction';
28+
import { UInt64 } from '../../src/model/UInt64';
29+
import { MosaicAliasTransaction } from '../../src/model/transaction/MosaicAliasTransaction';
30+
import { AliasActionType } from '../../src/model/namespace/AliasActionType';
2731

2832
describe('MosaicHttp', () => {
2933
let mosaicId: MosaicId;
3034
let mosaicHttp: MosaicHttp;
3135
let account: Account;
3236
let config;
37+
let namespaceId: NamespaceId;
3338
let transactionHttp: TransactionHttp;
3439
before((done) => {
3540
const path = require('path');
@@ -82,6 +87,74 @@ describe('MosaicHttp', () => {
8287
transactionHttp.announce(signedTransaction);
8388
});
8489
});
90+
91+
describe('Setup test NamespaceId', () => {
92+
let listener: Listener;
93+
before (() => {
94+
listener = new Listener(config.apiUrl);
95+
return listener.open();
96+
});
97+
after(() => {
98+
return listener.close();
99+
});
100+
it('Announce RegisterNamespaceTransaction', (done) => {
101+
const namespaceName = 'root-test-namespace-' + Math.floor(Math.random() * 10000);
102+
const registerNamespaceTransaction = RegisterNamespaceTransaction.createRootNamespace(
103+
Deadline.create(),
104+
namespaceName,
105+
UInt64.fromUint(1000),
106+
NetworkType.MIJIN_TEST,
107+
);
108+
namespaceId = new NamespaceId(namespaceName);
109+
const signedTransaction = registerNamespaceTransaction.signWith(account);
110+
listener.confirmed(account.address).subscribe((transaction) => {
111+
done();
112+
});
113+
listener.status(account.address).subscribe((error) => {
114+
console.log('Error:', error);
115+
assert(false);
116+
done();
117+
});
118+
transactionHttp.announce(signedTransaction);
119+
});
120+
});
121+
describe('Setup test MosaicAlias', () => {
122+
let listener: Listener;
123+
before (() => {
124+
listener = new Listener(config.apiUrl);
125+
return listener.open();
126+
});
127+
after(() => {
128+
return listener.close();
129+
});
130+
131+
it('Announce MosaicAliasTransaction', (done) => {
132+
const mosaicAliasTransaction = MosaicAliasTransaction.create(
133+
Deadline.create(),
134+
AliasActionType.Link,
135+
namespaceId,
136+
mosaicId,
137+
NetworkType.MIJIN_TEST,
138+
);
139+
const signedTransaction = mosaicAliasTransaction.signWith(account);
140+
141+
listener.confirmed(account.address).subscribe((transaction) => {
142+
done();
143+
});
144+
listener.status(account.address).subscribe((error) => {
145+
console.log('Error:', error);
146+
assert(false);
147+
done();
148+
});
149+
transactionHttp.announce(signedTransaction);
150+
});
151+
});
152+
153+
/**
154+
* =========================
155+
* Test
156+
* =========================
157+
*/
85158
describe('getMosaic', () => {
86159
it('should return mosaic given mosaicId', (done) => {
87160
mosaicHttp.getMosaic(mosaicId)
@@ -123,4 +196,50 @@ describe('MosaicHttp', () => {
123196
});
124197
});
125198
});
199+
200+
describe('getMosaicsNames', () => {
201+
it('should call getMosaicsNames successfully', (done) => {
202+
mosaicHttp.getMosaicsNames([mosaicId]).subscribe((mosaicNames) => {
203+
expect(mosaicNames.length).to.be.greaterThan(0);
204+
done();
205+
});
206+
});
207+
});
208+
209+
/**
210+
* =========================
211+
* House Keeping
212+
* =========================
213+
*/
214+
describe('Remove test MosaicAlias', () => {
215+
let listener: Listener;
216+
before (() => {
217+
listener = new Listener(config.apiUrl);
218+
return listener.open();
219+
});
220+
after(() => {
221+
return listener.close();
222+
});
223+
224+
it('Announce MosaicAliasTransaction', (done) => {
225+
const mosaicAliasTransaction = MosaicAliasTransaction.create(
226+
Deadline.create(),
227+
AliasActionType.Link,
228+
namespaceId,
229+
mosaicId,
230+
NetworkType.MIJIN_TEST,
231+
);
232+
const signedTransaction = mosaicAliasTransaction.signWith(account);
233+
234+
listener.confirmed(account.address).subscribe((transaction) => {
235+
done();
236+
});
237+
listener.status(account.address).subscribe((error) => {
238+
console.log('Error:', error);
239+
assert(false);
240+
done();
241+
});
242+
transactionHttp.announce(signedTransaction);
243+
});
244+
});
126245
});

0 commit comments

Comments
 (0)