Skip to content

Commit 64f088e

Browse files
author
Grégory Saive
authored
Merge branch 'master' into issue#24
2 parents 4f9ab35 + a2baae4 commit 64f088e

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

src/model/model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ export * from './transaction/AliasTransaction';
6464
export * from './transaction/CosignatureSignedTransaction';
6565
export * from './transaction/CosignatureTransaction';
6666
export * from './transaction/Deadline';
67+
export * from './transaction/HashLockTransaction';
6768
export * from './transaction/HashType';
6869
export * from './transaction/InnerTransaction';
6970
export * from './transaction/LockFundsTransaction';
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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 { LockFundsTransaction } from './LockFundsTransaction';
18+
19+
/*
20+
* An alias for LockFundsTransaction class
21+
*/
22+
export class HashLockTransaction extends LockFundsTransaction {
23+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
import {expect} from 'chai';
17+
import {NetworkType} from '../../../src/model/blockchain/NetworkType';
18+
import { NetworkCurrencyMosaic } from '../../../src/model/mosaic/NetworkCurrencyMosaic';
19+
import {AggregateTransaction} from '../../../src/model/transaction/AggregateTransaction';
20+
import {Deadline} from '../../../src/model/transaction/Deadline';
21+
import {HashLockTransaction} from '../../../src/model/transaction/HashLockTransaction';
22+
import {UInt64} from '../../../src/model/UInt64';
23+
import {TestingAccount} from '../../conf/conf.spec';
24+
25+
describe('HashLockTransaction', () => {
26+
const account = TestingAccount;
27+
it('creation with an aggregate bonded tx', () => {
28+
const aggregateTransaction = AggregateTransaction.createBonded(
29+
Deadline.create(),
30+
[],
31+
NetworkType.MIJIN_TEST,
32+
[],
33+
);
34+
const signedTransaction = account.sign(aggregateTransaction);
35+
const transaction = HashLockTransaction.create(Deadline.create(),
36+
NetworkCurrencyMosaic.createRelative(10),
37+
UInt64.fromUint(10),
38+
signedTransaction,
39+
NetworkType.MIJIN_TEST);
40+
expect(transaction.mosaic.id).to.be.equal(NetworkCurrencyMosaic.NAMESPACE_ID);
41+
expect(transaction.mosaic.amount.compact()).to.be.equal(10000000);
42+
expect(transaction.hash).to.be.equal(signedTransaction.hash);
43+
});
44+
45+
it('should throw exception if it is not a aggregate bonded tx', () => {
46+
const aggregateTransaction = AggregateTransaction.createComplete(
47+
Deadline.create(),
48+
[],
49+
NetworkType.MIJIN_TEST,
50+
[],
51+
);
52+
const signedTransaction = account.sign(aggregateTransaction);
53+
expect(() => {
54+
HashLockTransaction.create(Deadline.create(),
55+
NetworkCurrencyMosaic.createRelative(10),
56+
UInt64.fromUint(10),
57+
signedTransaction,
58+
NetworkType.MIJIN_TEST);
59+
}).to.throw(Error);
60+
});
61+
});

0 commit comments

Comments
 (0)