Skip to content

Commit 3513441

Browse files
committed
updated block chain routes and added e2e
1 parent 34c251a commit 3513441

File tree

9 files changed

+269
-148
lines changed

9 files changed

+269
-148
lines changed

e2e/infrastructure/AccountHttp.spec.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import { MultisigCosignatoryModification } from '../../src/model/transaction/Mul
3434
import { MultisigCosignatoryModificationType } from '../../src/model/transaction/MultisigCosignatoryModificationType';
3535
import { PlainMessage } from '../../src/model/transaction/PlainMessage';
3636
import { TransferTransaction } from '../../src/model/transaction/TransferTransaction';
37+
import { AggregateTransaction } from '../../src/model/transaction/AggregateTransaction';
3738

3839
describe('AccountHttp', () => {
3940
let account: Account;
@@ -236,7 +237,14 @@ describe('AccountHttp', () => {
236237
],
237238
NetworkType.MIJIN_TEST,
238239
);
239-
const signedTransaction = multisigAccount.sign(modifyMultisigAccountTransaction);
240+
241+
const aggregateTransaction = AggregateTransaction.createComplete(Deadline.create(),
242+
[modifyMultisigAccountTransaction.toAggregate(multisigAccount.publicAccount)],
243+
NetworkType.MIJIN_TEST,
244+
[]);
245+
const signedTransaction = aggregateTransaction
246+
.signTransactionWithCosignatories(multisigAccount, [cosignAccount1, cosignAccount2, cosignAccount3]);
247+
240248
listener.confirmed(multisigAccount.address).subscribe((transaction) => {
241249
done();
242250
});
@@ -247,6 +255,7 @@ describe('AccountHttp', () => {
247255
transactionHttp.announce(signedTransaction);
248256
});
249257
});
258+
250259
describe('getMultisigAccountGraphInfo', () => {
251260
it('should call getMultisigAccountGraphInfo successfully', (done) => {
252261
setTimeout(() => {
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
/*
2+
* Copyright 2018 NEM
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import {expect} from 'chai';
18+
import {BlockHttp} from '../../src/infrastructure/BlockHttp';
19+
import {QueryParams} from '../../src/infrastructure/QueryParams';
20+
21+
describe('BlockHttp', () => {
22+
let blockHttp: BlockHttp;
23+
let blockReceiptHash = '';
24+
let blockTransactionHash = '';
25+
before((done) => {
26+
const path = require('path');
27+
require('fs').readFile(path.resolve(__dirname, '../conf/network.conf'), (err, data) => {
28+
if (err) {
29+
throw err;
30+
}
31+
const json = JSON.parse(data);
32+
blockHttp = new BlockHttp(json.apiUrl);
33+
done();
34+
});
35+
});
36+
describe('getBlockByHeight', () => {
37+
it('should return block info given height', (done) => {
38+
blockHttp.getBlockByHeight(1)
39+
.subscribe((blockInfo) => {
40+
blockReceiptHash = blockInfo.blockReceiptsHash;
41+
blockTransactionHash = blockInfo.blockTransactionsHash;
42+
expect(blockInfo.height.lower).to.be.equal(1);
43+
expect(blockInfo.height.higher).to.be.equal(0);
44+
expect(blockInfo.timestamp.lower).to.be.equal(0);
45+
expect(blockInfo.timestamp.higher).to.be.equal(0);
46+
done();
47+
});
48+
});
49+
});
50+
51+
describe('getBlockTransactions', () => {
52+
let nextId: string;
53+
let firstId: string;
54+
55+
it('should return block transactions data given height', (done) => {
56+
blockHttp.getBlockTransactions(1)
57+
.subscribe((transactions) => {
58+
nextId = transactions[0].transactionInfo!.id;
59+
firstId = transactions[1].transactionInfo!.id;
60+
expect(transactions.length).to.be.greaterThan(0);
61+
done();
62+
});
63+
});
64+
65+
it('should return block transactions data given height with paginated transactionId', (done) => {
66+
blockHttp.getBlockTransactions(1, new QueryParams(10, nextId))
67+
.subscribe((transactions) => {
68+
expect(transactions[0].transactionInfo!.id).to.be.equal(firstId);
69+
expect(transactions.length).to.be.greaterThan(0);
70+
done();
71+
});
72+
});
73+
});
74+
75+
describe('getBlocksByHeightWithLimit', () => {
76+
it('should return block info given height and limit', (done) => {
77+
blockHttp.getBlocksByHeightWithLimit(1, 50)
78+
.subscribe((blocksInfo) => {
79+
expect(blocksInfo.length).to.be.greaterThan(0);
80+
done();
81+
});
82+
});
83+
});
84+
describe('getMerkleReceipts', () => {
85+
it('should return Merkle Receipts', (done) => {
86+
blockHttp.getMerkleReceipts(1, blockReceiptHash)
87+
.subscribe((merkleReceipts) => {
88+
expect(merkleReceipts.type).not.to.be.null;
89+
expect(merkleReceipts.payload).not.to.be.null;
90+
done();
91+
});
92+
});
93+
});
94+
describe('getMerkleTransaction', () => {
95+
it('should return Merkle Transaction', (done) => {
96+
blockHttp.getMerkleTransaction(1, blockTransactionHash)
97+
.subscribe((merkleTransactionss) => {
98+
expect(merkleTransactionss.type).not.to.be.null;
99+
expect(merkleTransactionss.payload).not.to.be.null;
100+
done();
101+
});
102+
});
103+
});
104+
105+
// describe('getBlockReceipts', () => {
106+
// it('should return block receipts', (done) => {
107+
// blockHttp.(1, '')
108+
// .subscribe((merkleTransactionss) => {
109+
// expect(merkleTransactionss.type).not.to.be.null;
110+
// expect(merkleTransactionss.payload).not.to.be.null;
111+
// done();
112+
// });
113+
// });
114+
// });
115+
});

e2e/infrastructure/BlockchainHttp.spec.ts

Lines changed: 0 additions & 113 deletions
This file was deleted.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2019 NEM
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import {expect} from 'chai';
18+
import {ChainHttp} from '../../src/infrastructure/ChainHttp';
19+
import {QueryParams} from '../../src/infrastructure/QueryParams';
20+
describe('ChainHttp', () => {
21+
let chainHttp: ChainHttp;
22+
before((done) => {
23+
const path = require('path');
24+
require('fs').readFile(path.resolve(__dirname, '../conf/network.conf'), (err, data) => {
25+
if (err) {
26+
throw err;
27+
}
28+
const json = JSON.parse(data);
29+
chainHttp = new ChainHttp(json.apiUrl);
30+
done();
31+
});
32+
});
33+
34+
describe('getBlockchainHeight', () => {
35+
it('should return blockchain height', (done) => {
36+
chainHttp.getBlockchainHeight()
37+
.subscribe((height) => {
38+
expect(height.lower).to.be.greaterThan(0);
39+
done();
40+
});
41+
});
42+
});
43+
44+
describe('getBlockchainScore', () => {
45+
it('should return blockchain score', (done) => {
46+
chainHttp.getBlockchainScore()
47+
.subscribe((blockchainScore) => {
48+
expect(blockchainScore.scoreLow).to.not.be.equal(undefined);
49+
expect(blockchainScore.scoreHigh.lower).to.be.equal(0);
50+
expect(blockchainScore.scoreHigh.higher).to.be.equal(0);
51+
done();
52+
});
53+
});
54+
});
55+
});
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
/*
2+
* Copyright 2019 NEM
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
import {expect} from 'chai';
18+
import {DiagnosticHttp} from '../../src/infrastructure/DiagnosticHttp';
19+
describe('DiagnosticHttp', () => {
20+
let diagnosticHttp: DiagnosticHttp;
21+
before((done) => {
22+
const path = require('path');
23+
require('fs').readFile(path.resolve(__dirname, '../conf/network.conf'), (err, data) => {
24+
if (err) {
25+
throw err;
26+
}
27+
const json = JSON.parse(data);
28+
diagnosticHttp = new DiagnosticHttp(json.apiUrl);
29+
done();
30+
});
31+
});
32+
33+
describe('getDiagnosticStorage', () => {
34+
it('should return diagnostic storage', (done) => {
35+
diagnosticHttp.getDiagnosticStorage()
36+
.subscribe((blockchainStorageInfo) => {
37+
expect(blockchainStorageInfo.numBlocks).to.be.greaterThan(0);
38+
expect(blockchainStorageInfo.numTransactions).to.be.greaterThan(0);
39+
expect(blockchainStorageInfo.numAccounts).to.be.greaterThan(0);
40+
done();
41+
});
42+
});
43+
});
44+
45+
describe('getServerInfo', () => {
46+
it('should return diagnostic storage', (done) => {
47+
diagnosticHttp.getServerInfo()
48+
.subscribe((serverInfo) => {
49+
expect(serverInfo.restVersion).not.to.be.null;
50+
expect(serverInfo.sdkVersion).not.to.be.null;
51+
done();
52+
});
53+
});
54+
});
55+
});

0 commit comments

Comments
 (0)