13
13
* See the License for the specific language governing permissions and
14
14
* limitations under the License.
15
15
*/
16
- import { AccountHttp } from '../../src/infrastructure/AccountHttp' ;
17
- import { Listener } from '../../src/infrastructure/Listener' ;
18
- import { Address } from '../../src/model/account/Address' ;
16
+ import { AccountHttp } from '../../src/infrastructure/AccountHttp' ;
17
+ import { Listener } from '../../src/infrastructure/Listener' ;
18
+ import { Address } from '../../src/model/account/Address' ;
19
19
import * as conf from '../conf/conf.spec' ;
20
20
import {
21
21
APIUrl , Cosignatory2Account , Cosignatory3Account , CosignatoryAccount , MultisigAccount ,
22
22
TestingAccount ,
23
23
} from '../conf/conf.spec' ;
24
- import { TransactionUtils } from './TransactionUtils' ;
24
+ import { TransactionUtils } from './TransactionUtils' ;
25
25
26
26
describe ( 'Listener' , ( ) => {
27
27
let account ;
@@ -40,64 +40,78 @@ describe('Listener', () => {
40
40
} ) ;
41
41
42
42
it ( 'newBlock' , ( done ) => {
43
- listener . newBlock ( ) . subscribe ( ( res ) => {
44
- done ( ) ;
45
- } ) ;
43
+ listener . newBlock ( )
44
+ . toPromise ( )
45
+ . then ( ( res ) => {
46
+ done ( ) ;
47
+ } ) ;
46
48
47
49
TransactionUtils . createAndAnnounce ( ) ;
48
50
} ) ;
49
51
50
52
it ( 'confirmedTransactionsGiven address signer' , ( done ) => {
51
- listener . confirmed ( account . address ) . subscribe ( ( res ) => {
52
- done ( ) ;
53
- } ) ;
53
+ listener . confirmed ( account . address )
54
+ . toPromise ( )
55
+ . then ( ( res ) => {
56
+ done ( ) ;
57
+ } ) ;
54
58
55
59
TransactionUtils . createAndAnnounce ( ) ;
56
60
} ) ;
57
61
58
62
it ( 'confirmedTransactionsGiven address recipient' , ( done ) => {
59
63
const recipientAddress = Address . createFromRawAddress ( 'SBILTA367K2LX2FEXG5TFWAS7GEFYAGY7QLFBYKC' ) ;
60
- listener . confirmed ( recipientAddress ) . subscribe ( ( res ) => {
61
- done ( ) ;
62
- } ) ;
64
+ listener . confirmed ( recipientAddress )
65
+ . toPromise ( )
66
+ . then ( ( res ) => {
67
+ done ( ) ;
68
+ } ) ;
63
69
64
70
TransactionUtils . createAndAnnounce ( ) ;
65
71
} ) ;
66
72
67
73
it ( 'unconfirmedTransactionsAdded' , ( done ) => {
68
- listener . unconfirmedAdded ( account . address ) . subscribe ( ( res ) => {
69
- done ( ) ;
70
- } ) ;
74
+ listener . unconfirmedAdded ( account . address )
75
+ . toPromise ( )
76
+ . then ( ( res ) => {
77
+ done ( ) ;
78
+ } ) ;
71
79
72
80
setTimeout ( ( ) => {
73
81
TransactionUtils . createAndAnnounce ( ) ;
74
82
} , 1000 ) ;
75
83
} ) ;
76
84
77
85
it ( 'unconfirmedTransactionsRemoved' , ( done ) => {
78
- listener . unconfirmedRemoved ( account . address ) . subscribe ( ( res ) => {
79
- done ( ) ;
80
- } ) ;
86
+ listener . unconfirmedRemoved ( account . address )
87
+ . toPromise ( )
88
+ . then ( ( res ) => {
89
+ done ( ) ;
90
+ } ) ;
81
91
82
92
setTimeout ( ( ) => {
83
93
TransactionUtils . createAndAnnounce ( ) ;
84
94
} , 1000 ) ;
85
95
} ) ;
86
96
87
97
it ( 'aggregateBondedTransactionsAdded' , ( done ) => {
88
- listener . aggregateBondedAdded ( multisigAccount . address ) . subscribe ( ( res ) => {
89
- done ( ) ;
90
- } ) ;
98
+ listener . aggregateBondedAdded ( multisigAccount . address )
99
+ . toPromise ( )
100
+ . then ( ( res ) => {
101
+ done ( ) ;
102
+ } ) ;
91
103
92
104
setTimeout ( ( ) => {
93
105
TransactionUtils . createAggregateBoundedTransactionAndAnnounce ( ) ;
94
106
} , 1000 ) ;
95
107
} ) ;
96
108
97
109
it ( 'aggregateBondedTransactionsRemoved' , ( done ) => {
98
- listener . aggregateBondedRemoved ( multisigAccount . address ) . subscribe ( ( res ) => {
99
- done ( ) ;
100
- } ) ;
110
+ listener . aggregateBondedRemoved ( multisigAccount . address )
111
+ . toPromise ( )
112
+ . then ( ( res ) => {
113
+ done ( ) ;
114
+ } ) ;
101
115
102
116
setTimeout ( ( ) => {
103
117
TransactionUtils . createAggregateBoundedTransactionAndAnnounce ( ) ;
@@ -112,9 +126,11 @@ describe('Listener', () => {
112
126
} ) ;
113
127
114
128
it ( 'cosignatureAdded' , ( done ) => {
115
- listener . cosignatureAdded ( multisigAccount . address ) . subscribe ( ( res ) => {
116
- done ( ) ;
117
- } ) ;
129
+ listener . cosignatureAdded ( multisigAccount . address )
130
+ . toPromise ( )
131
+ . then ( ( res ) => {
132
+ done ( ) ;
133
+ } ) ;
118
134
119
135
setTimeout ( ( ) => {
120
136
TransactionUtils . createAggregateBoundedTransactionAndAnnounce ( ) ;
@@ -128,9 +144,11 @@ describe('Listener', () => {
128
144
} ) ;
129
145
130
146
it ( 'transactionStatusGiven' , ( done ) => {
131
- listener . status ( account . address ) . subscribe ( ( res ) => {
132
- done ( ) ;
133
- } ) ;
147
+ listener . status ( account . address )
148
+ . toPromise ( )
149
+ . then ( ( res ) => {
150
+ done ( ) ;
151
+ } ) ;
134
152
135
153
setTimeout ( ( ) => {
136
154
TransactionUtils . createAndAnnounceWithInsufficientBalance ( ) ;
0 commit comments