Skip to content

Commit a9f9afc

Browse files
committed
Fixed rest e2e test issues
1 parent b6a0332 commit a9f9afc

File tree

8 files changed

+622
-361
lines changed

8 files changed

+622
-361
lines changed

e2e/conf/network.conf

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@
2424
"privateKey": "A7D6ED74CDDECBF621DDC63558433DB604FA800D138810B3DF9B4EC880D0705F",
2525
"address": "SD2UY5LHIAAZDVKRHBOYSS4MTLHVTJVUTQPEGV2U",
2626
"publicKey": "3A33DA75E00F643C49C57E8BD3282149911B06FF107C37F7AEDFED5532166BDA"
27+
},
28+
"cosignatory4Account": {
29+
"privateKey": "D2A12301F5595869EFD5374B3372F0ED7EC26BF73A71D310950CC018D3FA0B03",
30+
"address": "SD7PYMM2BTT4SGSITZ2MBQBK4SXIQQQV4ZOP46VF",
31+
"publicKey": "FDE589878756C2287056EC8D7B2829D9C1FA6D389EBDC808034813FE7810AAB0"
2732
},
2833
"testAccount2": {
2934
"privateKey": "E5DCCEBDB01A8B03A7DB7BA5888E2E33FD4617B5F6FED48C4C09C0780F422713",
@@ -40,19 +45,9 @@
4045
"address": "SC5NTT5APX2FAUS4VQUII3UTMAD7GHRFTLDQOEDW",
4146
"publicKey": "6D652E480E5B2997A19D0C7485724693D79A63FCD591A948B40240BD196BA7D6"
4247
},
43-
"testRemoteAccount": {
48+
"harvestingAccount": {
4449
"privateKey": "0B9802C011DA2D61BCD203F4DC76C012898EE38BA54A7E030B86630A8FD43CA6",
4550
"address": "SAALWHKCWH72J53M3M4LB6UYFGLQMAOXJACWJX2U",
4651
"publicKey": "092CAAFEBCB51C64A7CE423050964492407B264CA306D063DBA927A2304C4DD8"
47-
},
48-
"defaultMosaicId": [2464780594, 28014280],
49-
"namespace": {
50-
"id": [3383943863,3847476908],
51-
"name": "e2etest",
52-
"linkedAddress": "SBMYYFIM6VGG45KWGSZLSXFHP74WVT7MOF6UYBHT"
53-
},
54-
"testTransaction": {
55-
"transactionHash": "716A5A6DE19EA409752A088B128403FA39AF7549D1EA23DBC0876276E0EE0089",
56-
"transactionId": "5CD48DAA36DA0C000172FF77"
5752
}
5853
}

e2e/infrastructure/AccountHttp.spec.ts

Lines changed: 187 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,41 @@
1515
*/
1616

1717
import {deepEqual} from 'assert';
18-
import {expect} from 'chai';
18+
import {assert, expect} from 'chai';
1919
import {AccountHttp} from '../../src/infrastructure/AccountHttp';
20+
import { Listener, TransactionHttp } from '../../src/infrastructure/infrastructure';
2021
import {QueryParams} from '../../src/infrastructure/QueryParams';
22+
import { Account } from '../../src/model/account/Account';
2123
import {Address} from '../../src/model/account/Address';
24+
import { PropertyModificationType } from '../../src/model/account/PropertyModificationType';
25+
import { PropertyType } from '../../src/model/account/PropertyType';
2226
import {PublicAccount} from '../../src/model/account/PublicAccount';
2327
import {NetworkType} from '../../src/model/blockchain/NetworkType';
28+
import { NetworkCurrencyMosaic } from '../../src/model/mosaic/NetworkCurrencyMosaic';
29+
import { AccountPropertyModification } from '../../src/model/transaction/AccountPropertyModification';
30+
import { AccountPropertyTransaction } from '../../src/model/transaction/AccountPropertyTransaction';
31+
import { Deadline } from '../../src/model/transaction/Deadline';
32+
import { ModifyMultisigAccountTransaction } from '../../src/model/transaction/ModifyMultisigAccountTransaction';
33+
import { MultisigCosignatoryModification } from '../../src/model/transaction/MultisigCosignatoryModification';
34+
import { MultisigCosignatoryModificationType } from '../../src/model/transaction/MultisigCosignatoryModificationType';
35+
import { PlainMessage } from '../../src/model/transaction/PlainMessage';
36+
import { TransferTransaction } from '../../src/model/transaction/TransferTransaction';
2437

2538
describe('AccountHttp', () => {
39+
let account: Account;
40+
let account2: Account;
41+
let account3: Account;
42+
let multisigAccount: Account;
43+
let cosignAccount1: Account;
44+
let cosignAccount2: Account;
45+
let cosignAccount3: Account;
2646
let accountAddress: Address;
2747
let accountPublicKey: string;
2848
let publicAccount: PublicAccount;
2949
let multisigPublicAccount: PublicAccount;
3050
let accountHttp: AccountHttp;
51+
let transactionHttp: TransactionHttp;
52+
let config;
3153

3254
before((done) => {
3355
const path = require('path');
@@ -36,16 +58,55 @@ describe('AccountHttp', () => {
3658
throw err;
3759
}
3860
const json = JSON.parse(data);
39-
61+
config = json;
62+
account = Account.createFromPrivateKey(json.testAccount.privateKey, NetworkType.MIJIN_TEST);
63+
account2 = Account.createFromPrivateKey(json.testAccount2.privateKey, NetworkType.MIJIN_TEST);
64+
account3 = Account.createFromPrivateKey(json.testAccount3.privateKey, NetworkType.MIJIN_TEST);
65+
multisigAccount = Account.createFromPrivateKey(json.multisigAccount.privateKey, NetworkType.MIJIN_TEST);
66+
cosignAccount1 = Account.createFromPrivateKey(json.cosignatoryAccount.privateKey, NetworkType.MIJIN_TEST);
67+
cosignAccount2 = Account.createFromPrivateKey(json.cosignatory2Account.privateKey, NetworkType.MIJIN_TEST);
68+
cosignAccount3 = Account.createFromPrivateKey(json.cosignatory3Account.privateKey, NetworkType.MIJIN_TEST);
4069
accountAddress = Address.createFromRawAddress(json.testAccount.address);
4170
accountPublicKey = json.testAccount.publicKey;
4271
publicAccount = PublicAccount.createFromPublicKey(json.testAccount.publicKey, NetworkType.MIJIN_TEST);
4372
multisigPublicAccount = PublicAccount.createFromPublicKey(json.multisigAccount.publicKey, NetworkType.MIJIN_TEST);
4473

4574
accountHttp = new AccountHttp(json.apiUrl);
75+
transactionHttp = new TransactionHttp(json.apiUrl);
4676
done();
4777
});
4878
});
79+
describe('TransferTransaction', () => {
80+
let listener: Listener;
81+
before (() => {
82+
listener = new Listener(config.apiUrl);
83+
return listener.open();
84+
});
85+
after(() => {
86+
return listener.close();
87+
});
88+
89+
it('standalone', (done) => {
90+
const transferTransaction = TransferTransaction.create(
91+
Deadline.create(),
92+
account2.address,
93+
[NetworkCurrencyMosaic.createAbsolute(1)],
94+
PlainMessage.create('test-message'),
95+
NetworkType.MIJIN_TEST,
96+
);
97+
const signedTransaction = transferTransaction.signWith(account);
98+
99+
listener.confirmed(account.address).subscribe((transaction) => {
100+
done();
101+
});
102+
listener.status(account.address).subscribe((error) => {
103+
console.log('Error:', error);
104+
assert(false);
105+
done();
106+
});
107+
transactionHttp.announce(signedTransaction);
108+
});
109+
});
49110

50111
describe('getAccountInfo', () => {
51112
it('should return account data given a NEM Address', (done) => {
@@ -67,41 +128,148 @@ describe('AccountHttp', () => {
67128
});
68129
});
69130

70-
describe('getMultisigAccountInfo', () => {
71-
it('should call getMultisigAccountInfo successfully', (done) => {
72-
accountHttp.getMultisigAccountInfo(multisigPublicAccount.address).subscribe((multisigAccountInfo) => {
73-
expect(multisigAccountInfo.account.publicKey).to.be.equal(multisigPublicAccount.publicKey);
131+
describe('AccountPropertyTransaction - Address', () => {
132+
let listener: Listener;
133+
before (() => {
134+
listener = new Listener(config.apiUrl);
135+
return listener.open();
136+
});
137+
after(() => {
138+
return listener.close();
139+
});
140+
141+
it('add properties', (done) => {
142+
const addressPropertyFilter = AccountPropertyModification.createForAddress(
143+
PropertyModificationType.Add,
144+
account3.address,
145+
);
146+
const addressModification = AccountPropertyTransaction.createAddressPropertyModificationTransaction(
147+
Deadline.create(),
148+
PropertyType.BlockAddress,
149+
[addressPropertyFilter],
150+
NetworkType.MIJIN_TEST,
151+
);
152+
const signedTransaction = addressModification.signWith(account);
153+
154+
listener.confirmed(account.address).subscribe((transaction) => {
74155
done();
75156
});
157+
listener.status(account.address).subscribe((error) => {
158+
console.log('Error:', error);
159+
assert(false);
160+
done();
161+
});
162+
transactionHttp.announce(signedTransaction);
76163
});
77164
});
78165

79166
describe('getAccountProperty', () => {
80167
it('should call getAccountProperty successfully', (done) => {
81-
accountHttp.getAccountProperty(accountAddress).subscribe((accountProperty) => {
82-
deepEqual(accountProperty.accountProperties.address, accountAddress);
83-
done();
84-
});
168+
setTimeout(() => {
169+
accountHttp.getAccountProperty(accountAddress).subscribe((accountProperty) => {
170+
deepEqual(accountProperty.accountProperties.address, accountAddress);
171+
done();
172+
});
173+
}, 1000);
85174
});
86175
});
87176

88177
describe('getAccountProperties', () => {
89178
it('should call getAccountProperties successfully', (done) => {
90-
accountHttp.getAccountProperties([accountAddress]).subscribe((accountProperties) => {
91-
deepEqual(accountProperties[0]!.accountProperties.address, accountAddress);
179+
setTimeout(() => {
180+
accountHttp.getAccountProperties([accountAddress]).subscribe((accountProperties) => {
181+
deepEqual(accountProperties[0]!.accountProperties.address, accountAddress);
182+
done();
183+
});
184+
});
185+
});
186+
});
187+
describe('AccountPropertyTransaction - Address', () => {
188+
let listener: Listener;
189+
before (() => {
190+
listener = new Listener(config.apiUrl);
191+
return listener.open();
192+
});
193+
after(() => {
194+
return listener.close();
195+
});
196+
197+
it('remove properties', (done) => {
198+
const addressPropertyFilter = AccountPropertyModification.createForAddress(
199+
PropertyModificationType.Remove,
200+
account3.address,
201+
);
202+
const addressModification = AccountPropertyTransaction.createAddressPropertyModificationTransaction(
203+
Deadline.create(),
204+
PropertyType.BlockAddress,
205+
[addressPropertyFilter],
206+
NetworkType.MIJIN_TEST,
207+
);
208+
const signedTransaction = addressModification.signWith(account);
209+
210+
listener.confirmed(account.address).subscribe((transaction) => {
211+
done();
212+
});
213+
listener.status(account.address).subscribe((error) => {
214+
console.log('Error:', error);
215+
assert(false);
216+
done();
217+
});
218+
transactionHttp.announce(signedTransaction);
219+
});
220+
});
221+
describe('ModifyMultisigAccountTransaction', () => {
222+
let listener: Listener;
223+
before (() => {
224+
listener = new Listener(config.apiUrl);
225+
return listener.open();
226+
});
227+
after(() => {
228+
return listener.close();
229+
});
230+
it('ModifyMultisigAccountTransaction', (done) => {
231+
const modifyMultisigAccountTransaction = ModifyMultisigAccountTransaction.create(
232+
Deadline.create(),
233+
2,
234+
1,
235+
[ new MultisigCosignatoryModification(MultisigCosignatoryModificationType.Add, cosignAccount1.publicAccount),
236+
new MultisigCosignatoryModification(MultisigCosignatoryModificationType.Add, cosignAccount2.publicAccount),
237+
new MultisigCosignatoryModification(MultisigCosignatoryModificationType.Add, cosignAccount3.publicAccount),
238+
],
239+
NetworkType.MIJIN_TEST,
240+
);
241+
const signedTransaction = multisigAccount.sign(modifyMultisigAccountTransaction);
242+
listener.confirmed(multisigAccount.address).subscribe((transaction) => {
243+
done();
244+
});
245+
listener.status(multisigAccount.address).subscribe((error) => {
246+
console.log('Error:', error);
92247
done();
93248
});
249+
transactionHttp.announce(signedTransaction);
94250
});
95251
});
96252
describe('getMultisigAccountGraphInfo', () => {
97253
it('should call getMultisigAccountGraphInfo successfully', (done) => {
98-
accountHttp.getMultisigAccountGraphInfo(multisigPublicAccount.address).subscribe((multisigAccountGraphInfo) => {
99-
expect(multisigAccountGraphInfo.multisigAccounts.get(0)![0].account.publicKey).to.be.equal(multisigPublicAccount.publicKey);
100-
done();
254+
setTimeout(() => {
255+
accountHttp.getMultisigAccountGraphInfo(multisigPublicAccount.address).subscribe((multisigAccountGraphInfo) => {
256+
expect(multisigAccountGraphInfo.multisigAccounts.get(0)![0].
257+
account.publicKey).to.be.equal(multisigPublicAccount.publicKey);
258+
done();
259+
});
260+
});
261+
});
262+
});
263+
describe('getMultisigAccountInfo', () => {
264+
it('should call getMultisigAccountInfo successfully', (done) => {
265+
setTimeout(() => {
266+
accountHttp.getMultisigAccountInfo(multisigPublicAccount.address).subscribe((multisigAccountInfo) => {
267+
expect(multisigAccountInfo.account.publicKey).to.be.equal(multisigPublicAccount.publicKey);
268+
done();
269+
});
101270
});
102271
});
103272
});
104-
105273
describe('incomingTransactions', () => {
106274
it('should call incomingTransactions successfully', (done) => {
107275
accountHttp.incomingTransactions(publicAccount).subscribe((transactions) => {
@@ -121,29 +289,15 @@ describe('AccountHttp', () => {
121289
done();
122290
});
123291
});
124-
// it('should call outgoingTransactions successfully pageSize 11', (done) => {
125-
// accountHttp.outgoingTransactions(publicAccount, new QueryParams(22)).subscribe((transactions) => {
126-
// expect(transactions.length).to.be.equal(2);
127-
// nextId = transactions[10].transactionInfo!.id;
128-
// lastId = transactions[11].transactionInfo!.id;
129-
// done();
130-
// });
131-
// });
132-
133-
// it('should call outgoingTransactions successfully pageSize 11 and next id', (done) => {
134-
// accountHttp.outgoingTransactions(publicAccount, new QueryParams(11, nextId)).subscribe((transactions) => {
135-
// expect(transactions.length).to.be.equal(2);
136-
// expect(transactions[0].transactionInfo!.id).to.be.equal(lastId);
137-
// done();
138-
// });
139-
// });
140292
});
141293

142294
describe('aggregateBondedTransactions', () => {
143295
it('should call aggregateBondedTransactions successfully', (done) => {
144296
accountHttp.aggregateBondedTransactions(publicAccount).subscribe((transactions) => {
145-
expect(transactions.length).to.be.equal(0);
146297
done();
298+
}, (error) => {
299+
console.log('Error:', error);
300+
assert(false);
147301
});
148302
});
149303
});

0 commit comments

Comments
 (0)