99 bobAddress ,
1010} from '../fixture/vars' ;
1111import { getTxOutputs } from '../test-util' ;
12- import { FailedTransactionError } from '../../src/Errors' ;
12+ import { FailedRequireError , Reason } from '../../src/Errors' ;
1313
1414// Mecenas has tx.age check omitted for testing
1515describe ( 'Mecenas v1' , ( ) => {
@@ -26,44 +26,50 @@ describe('Mecenas v1', () => {
2626 const to = aliceAddress ;
2727 const amount = pledge + 10 ;
2828
29- // then
29+ // when
3030 const expectPromise = expect (
3131 mecenas . functions
3232 . receive ( alicePk , new Sig ( alice ) )
3333 . send ( to , amount , { fee : 1000 } ) ,
3434 ) ;
35- await expectPromise . rejects . toThrow ( FailedTransactionError ) ;
36- await expectPromise . rejects . toThrow ( 'Script evaluated without error but finished with a false/empty top stack element' ) ;
35+
36+ // then
37+ await expectPromise . rejects . toThrow ( FailedRequireError ) ;
38+ await expectPromise . rejects . toThrow ( Reason . EVAL_FALSE ) ;
3739 } ) ;
3840
3941 it ( 'should fail when trying to send to wrong person' , async ( ) => {
4042 // given
4143 const to = bobAddress ;
4244 const amount = pledge ;
4345
44- // then
46+ // when
4547 const expectPromise = expect (
4648 mecenas . functions
4749 . receive ( alicePk , new Sig ( alice ) )
4850 . send ( to , amount , { fee : 1000 } ) ,
4951 ) ;
50- await expectPromise . rejects . toThrow ( FailedTransactionError ) ;
51- await expectPromise . rejects . toThrow ( 'Script evaluated without error but finished with a false/empty top stack element' ) ;
52+
53+ // then
54+ await expectPromise . rejects . toThrow ( FailedRequireError ) ;
55+ await expectPromise . rejects . toThrow ( Reason . EVAL_FALSE ) ;
5256 } ) ;
5357
5458 it ( 'should fail when trying to send to multiple people' , async ( ) => {
5559 // given
5660 const to = aliceAddress ;
5761 const amount = pledge ;
5862
59- // then
63+ // when
6064 const expectPromise = expect (
6165 mecenas . functions
6266 . receive ( alicePk , new Sig ( alice ) )
6367 . send ( [ { to, amount } , { to, amount } ] , { fee : 1000 } ) ,
6468 ) ;
65- await expectPromise . rejects . toThrow ( FailedTransactionError ) ;
66- await expectPromise . rejects . toThrow ( 'Script evaluated without error but finished with a false/empty top stack element' ) ;
69+
70+ // then
71+ await expectPromise . rejects . toThrow ( FailedRequireError ) ;
72+ await expectPromise . rejects . toThrow ( Reason . EVAL_FALSE ) ;
6773 } ) ;
6874
6975 it ( 'should succeed when sending pledge to receiver' , async ( ) => {
@@ -98,44 +104,50 @@ describe('Mecenas', () => {
98104 const to = aliceAddress ;
99105 const amount = pledge + 10 ;
100106
101- // then
107+ // when
102108 const expectPromise = expect (
103109 mecenas . functions
104110 . receive ( alicePk , new Sig ( alice ) )
105111 . send ( to , amount , { fee : 1000 } ) ,
106112 ) ;
107- await expectPromise . rejects . toThrow ( FailedTransactionError ) ;
108- await expectPromise . rejects . toThrow ( 'Script failed an OP_EQUALVERIFY operation' ) ;
113+
114+ // then
115+ await expectPromise . rejects . toThrow ( FailedRequireError ) ;
116+ await expectPromise . rejects . toThrow ( Reason . EQUALVERIFY ) ;
109117 } ) ;
110118
111119 it ( 'should fail when trying to send to wrong person' , async ( ) => {
112120 // given
113121 const to = bobAddress ;
114122 const amount = pledge ;
115123
116- // then
124+ // when
117125 const expectPromise = expect (
118126 mecenas . functions
119127 . receive ( alicePk , new Sig ( alice ) )
120128 . send ( to , amount , { fee : 1000 } ) ,
121129 ) ;
122- await expectPromise . rejects . toThrow ( FailedTransactionError ) ;
123- await expectPromise . rejects . toThrow ( 'Script failed an OP_EQUALVERIFY operation' ) ;
130+
131+ // then
132+ await expectPromise . rejects . toThrow ( FailedRequireError ) ;
133+ await expectPromise . rejects . toThrow ( Reason . EQUALVERIFY ) ;
124134 } ) ;
125135
126136 it ( 'should fail when trying to send to multiple people' , async ( ) => {
127137 // given
128138 const to = aliceAddress ;
129139 const amount = pledge ;
130140
131- // then
141+ // when
132142 const expectPromise = expect (
133143 mecenas . functions
134144 . receive ( alicePk , new Sig ( alice ) )
135145 . send ( [ { to, amount } , { to, amount } ] , { fee : 1000 } ) ,
136146 ) ;
137- await expectPromise . rejects . toThrow ( FailedTransactionError ) ;
138- await expectPromise . rejects . toThrow ( 'Script failed an OP_EQUALVERIFY operation' ) ;
147+
148+ // then
149+ await expectPromise . rejects . toThrow ( FailedRequireError ) ;
150+ await expectPromise . rejects . toThrow ( Reason . EQUALVERIFY ) ;
139151 } ) ;
140152
141153 it ( 'should succeed when sending pledge to receiver' , async ( ) => {
0 commit comments