Skip to content

Commit

Permalink
[issue-664]: add some test case for unresolved address
Browse files Browse the repository at this point in the history
  • Loading branch information
boldchains committed Dec 2, 2020
1 parent fded9e7 commit a8cb984
Showing 1 changed file with 66 additions and 2 deletions.
68 changes: 66 additions & 2 deletions e2e/infrastructure/Listener.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ import { filter, mergeMap } from 'rxjs/operators';
import { TransactionSearchCriteria } from '../../src/infrastructure/searchCriteria/TransactionSearchCriteria';
import { TransactionGroup } from '../../src/infrastructure/TransactionGroup';
import { TransactionRepository } from '../../src/infrastructure/TransactionRepository';
import { Account, Address } from '../../src/model/account';
import { Account, UnresolvedAddress } from '../../src/model/account';
import { PlainMessage } from '../../src/model/message/PlainMessage';
import { Currency } from '../../src/model/mosaic';
import { NamespaceId } from '../../src/model/namespace';
import { NetworkType } from '../../src/model/network/NetworkType';
import { AggregateTransaction } from '../../src/model/transaction/AggregateTransaction';
import { CosignatureTransaction } from '../../src/model/transaction/CosignatureTransaction';
Expand All @@ -44,6 +45,7 @@ describe('Listener', () => {
let generationHash: string;
let networkType: NetworkType;
let transactionRepository: TransactionRepository;
const unresolvedAddress = new NamespaceId('address');

before(() => {
return helper.start({ openListener: true }).then(() => {
Expand All @@ -67,7 +69,11 @@ describe('Listener', () => {
setTimeout(done, 200);
});

const createSignedAggregatedBondTransaction = (aggregatedTo: Account, signer: Account, recipient: Address): SignedTransaction => {
const createSignedAggregatedBondTransaction = (
aggregatedTo: Account,
signer: Account,
recipient: UnresolvedAddress,
): SignedTransaction => {
const transferTransaction = TransferTransaction.create(
Deadline.create(helper.epochAdjustment),
recipient,
Expand Down Expand Up @@ -175,6 +181,46 @@ describe('Listener', () => {
});
});

describe('UnConfirmed', () => {
it('unconfirmedTransactionsAdded with unresolved address', (done) => {
const transferTransaction = TransferTransaction.create(
Deadline.create(helper.epochAdjustment),
unresolvedAddress,
[],
PlainMessage.create('test-message'),
networkType,
helper.maxFee,
);
const signedTransaction = account.sign(transferTransaction, generationHash);
helper.listener
.unconfirmedAdded(unresolvedAddress)
.pipe(filter((_) => _.transactionInfo!.hash === signedTransaction.hash))
.subscribe(() => {
done();
});
transactionRepository.announce(signedTransaction);
});

it('unconfirmedTransactionsRemoved with unresolved address', (done) => {
const transferTransaction = TransferTransaction.create(
Deadline.create(helper.epochAdjustment),
unresolvedAddress,
[],
PlainMessage.create('test-message'),
networkType,
helper.maxFee,
);
const signedTransaction = account.sign(transferTransaction, generationHash);
helper.listener
.unconfirmedRemoved(unresolvedAddress)
.pipe(filter((hash) => hash === signedTransaction.hash))
.subscribe(() => {
done();
});
transactionRepository.announce(signedTransaction);
});
});

describe('TransferTransaction', () => {
it('standalone', () => {
const transferTransaction = TransferTransaction.create(
Expand Down Expand Up @@ -312,6 +358,24 @@ describe('Listener', () => {
});
});

describe('Aggregate Bonded Transactions', () => {
it('aggregateBondedTransactionsAdded', (done) => {
const signedAggregatedTx = createSignedAggregatedBondTransaction(multisigAccount, account, account2.address);
createHashLockTransactionAndAnnounce(signedAggregatedTx, account, helper.networkCurrency);
helper.listener.aggregateBondedAdded(unresolvedAddress).subscribe(() => {
done();
});
helper.listener.confirmed(unresolvedAddress).subscribe(() => {
transactionRepository.announceAggregateBonded(signedAggregatedTx);
});
helper.listener.status(unresolvedAddress).subscribe((error) => {
console.log('Error:', error);
assert(false);
done();
});
});
});

describe('MultisigAccountModificationTransaction - Restore multisig Accounts', () => {
it('Restore Multisig Account', () => {
const removeCosigner1 = MultisigAccountModificationTransaction.create(
Expand Down

0 comments on commit a8cb984

Please sign in to comment.