@@ -17,91 +17,88 @@ import { getTxOutputs } from '../../test-util.js';
1717import { FailedTransactionError } from '../../../src/Errors.js' ;
1818import artifact from '../../fixture/old/mecenas.json' with { type : 'json' } ;
1919
20- if ( ! process . env . TESTS_USE_MOCKNET ) {
21- // Mecenas has tx.age check omitted for testing
22- describe ( 'v0.6.0 - Mecenas' , ( ) => {
23- let mecenas : Contract ;
24- const pledge = 10000n ;
25- const minerFee = 1000n ;
20+ const describeOrSkip = process . env . TESTS_USE_MOCKNET ? describe . skip : describe ;
2621
27- beforeAll ( ( ) => {
28- const provider = new ElectrumNetworkProvider ( Network . CHIPNET ) ;
29- const addressType = 'p2sh20' ;
30- mecenas = new Contract ( artifact , [ alicePkh , bobPkh , pledge ] , { provider, addressType } ) ;
31- console . log ( mecenas . address ) ;
32- } ) ;
22+ describeOrSkip ( 'v0.6.0 - Mecenas' , ( ) => {
23+ let mecenas : Contract ;
24+ const pledge = 10000n ;
25+ const minerFee = 1000n ;
26+
27+ beforeAll ( ( ) => {
28+ const provider = new ElectrumNetworkProvider ( Network . CHIPNET ) ;
29+ const addressType = 'p2sh20' ;
30+ mecenas = new Contract ( artifact , [ alicePkh , bobPkh , pledge ] , { provider, addressType } ) ;
31+ console . log ( mecenas . address ) ;
32+ } ) ;
3333
34- describe ( 'send' , ( ) => {
35- it ( 'should fail when trying to send more than pledge' , async ( ) => {
34+ describe ( 'send' , ( ) => {
35+ it ( 'should fail when trying to send more than pledge' , async ( ) => {
3636 // given
37- const to = aliceAddress ;
38- const amount = pledge + 10n ;
37+ const to = aliceAddress ;
38+ const amount = pledge + 10n ;
3939
40- // when
41- const txPromise = mecenas . functions
42- . receive ( alicePub , new SignatureTemplate ( alicePriv , HashType . SIGHASH_ALL ) )
43- . to ( to , amount )
44- . withHardcodedFee ( minerFee )
45- . send ( ) ;
40+ // when
41+ const txPromise = mecenas . functions
42+ . receive ( alicePub , new SignatureTemplate ( alicePriv , HashType . SIGHASH_ALL ) )
43+ . to ( to , amount )
44+ . withHardcodedFee ( minerFee )
45+ . send ( ) ;
4646
47- // then
48- await expect ( txPromise ) . rejects . toThrow ( FailedTransactionError ) ;
49- await expect ( txPromise ) . rejects . toThrow ( 'Script failed an OP_EQUALVERIFY operation' ) ;
50- } ) ;
47+ // then
48+ await expect ( txPromise ) . rejects . toThrow ( FailedTransactionError ) ;
49+ await expect ( txPromise ) . rejects . toThrow ( 'Script failed an OP_EQUALVERIFY operation' ) ;
50+ } ) ;
5151
52- it ( 'should fail when trying to send to wrong person' , async ( ) => {
52+ it ( 'should fail when trying to send to wrong person' , async ( ) => {
5353 // given
54- const to = bobAddress ;
55- const amount = pledge ;
54+ const to = bobAddress ;
55+ const amount = pledge ;
5656
57- // when
58- const txPromise = mecenas . functions
59- . receive ( alicePub , new SignatureTemplate ( alicePriv , HashType . SIGHASH_ALL ) )
60- . to ( to , amount )
61- . withHardcodedFee ( minerFee )
62- . send ( ) ;
57+ // when
58+ const txPromise = mecenas . functions
59+ . receive ( alicePub , new SignatureTemplate ( alicePriv , HashType . SIGHASH_ALL ) )
60+ . to ( to , amount )
61+ . withHardcodedFee ( minerFee )
62+ . send ( ) ;
6363
64- // then
65- await expect ( txPromise ) . rejects . toThrow ( FailedTransactionError ) ;
66- await expect ( txPromise ) . rejects . toThrow ( 'Script failed an OP_EQUALVERIFY operation' ) ;
67- } ) ;
64+ // then
65+ await expect ( txPromise ) . rejects . toThrow ( FailedTransactionError ) ;
66+ await expect ( txPromise ) . rejects . toThrow ( 'Script failed an OP_EQUALVERIFY operation' ) ;
67+ } ) ;
6868
69- it ( 'should fail when trying to send to multiple people' , async ( ) => {
69+ it ( 'should fail when trying to send to multiple people' , async ( ) => {
7070 // given
71- const to = aliceAddress ;
72- const amount = pledge ;
71+ const to = aliceAddress ;
72+ const amount = pledge ;
7373
74- // when
75- const txPromise = mecenas . functions
76- . receive ( alicePub , new SignatureTemplate ( alicePriv , HashType . SIGHASH_ALL ) )
77- . to ( to , amount )
78- . to ( to , amount )
79- . withHardcodedFee ( minerFee )
80- . send ( ) ;
74+ // when
75+ const txPromise = mecenas . functions
76+ . receive ( alicePub , new SignatureTemplate ( alicePriv , HashType . SIGHASH_ALL ) )
77+ . to ( to , amount )
78+ . to ( to , amount )
79+ . withHardcodedFee ( minerFee )
80+ . send ( ) ;
8181
82- // then
83- await expect ( txPromise ) . rejects . toThrow ( FailedTransactionError ) ;
84- await expect ( txPromise ) . rejects . toThrow ( 'Script failed an OP_EQUALVERIFY operation' ) ;
85- } ) ;
82+ // then
83+ await expect ( txPromise ) . rejects . toThrow ( FailedTransactionError ) ;
84+ await expect ( txPromise ) . rejects . toThrow ( 'Script failed an OP_EQUALVERIFY operation' ) ;
85+ } ) ;
8686
87- it ( 'should succeed when sending pledge to receiver' , async ( ) => {
87+ it ( 'should succeed when sending pledge to receiver' , async ( ) => {
8888 // given
89- const to = aliceAddress ;
90- const amount = pledge ;
89+ const to = aliceAddress ;
90+ const amount = pledge ;
9191
92- // when
93- const tx = await mecenas . functions
94- . receive ( alicePub , new SignatureTemplate ( alicePriv , HashType . SIGHASH_ALL ) )
95- . to ( to , amount )
96- . withHardcodedFee ( minerFee )
97- . send ( ) ;
92+ // when
93+ const tx = await mecenas . functions
94+ . receive ( alicePub , new SignatureTemplate ( alicePriv , HashType . SIGHASH_ALL ) )
95+ . to ( to , amount )
96+ . withHardcodedFee ( minerFee )
97+ . send ( ) ;
9898
99- // then
100- const txOutputs = getTxOutputs ( tx ) ;
101- expect ( txOutputs ) . toEqual ( expect . arrayContaining ( [ { to, amount } ] ) ) ;
102- } ) ;
99+ // then
100+ const txOutputs = getTxOutputs ( tx ) ;
101+ expect ( txOutputs ) . toEqual ( expect . arrayContaining ( [ { to, amount } ] ) ) ;
103102 } ) ;
104103 } ) ;
105- } else {
106- test . skip ( 'skip' , ( ) => { } ) ;
107- }
104+ } ) ;
0 commit comments