@@ -4,6 +4,7 @@ import * as path from 'path';
4
4
import { DecodedTxResult , TxPayloadTypeID } from 'stacks-encoding-native-js' ;
5
5
import { CoreNodeBlockMessage } from '../event-stream/core-node-message' ;
6
6
import { parseMessageTransaction } from '../event-stream/reader' ;
7
+ import { parseNewBlockMessage } from '../event-stream/event-server' ;
7
8
8
9
// Test processing of the psuedo-Stacks transactions, i.e. the ones that
9
10
// originate on the Bitcoin chain, and have a `raw_tx == '0x00'.
@@ -194,6 +195,34 @@ describe('synthetic stx txs', () => {
194
195
expect ( parsed . parsed_tx ) . toEqual ( expect . objectContaining ( expected ) ) ;
195
196
} ) ;
196
197
198
+ test ( 'test synthetic tx stx lock 3' , ( ) => {
199
+ const file =
200
+ 'synthetic-tx-payloads/stx_lock-1994-0xd45e090ac442380cf50655e3d1c904c355a501d6dffa3b5e4799083062469dbc.json' ;
201
+ const txid = file . split ( '-' ) . slice ( - 1 ) [ 0 ] . split ( '.' ) [ 0 ] ;
202
+ const payloadStr = fs . readFileSync ( path . join ( __dirname , file ) , { encoding : 'utf8' } ) ;
203
+ const blockMsg = JSON . parse ( payloadStr ) as CoreNodeBlockMessage ;
204
+ const txMsg = blockMsg . transactions . find ( t => t . txid === txid ) ;
205
+ if ( ! txMsg ) {
206
+ throw new Error ( `Cound not find tx ${ txid } ` ) ;
207
+ }
208
+ const parsed = parseNewBlockMessage ( ChainID . Mainnet , blockMsg ) ;
209
+ if ( ! parsed ) {
210
+ throw new Error ( `Failed to parse ${ txid } ` ) ;
211
+ }
212
+ // Ensure real contract event indexes are contiguous
213
+ const events = [ parsed . txs [ 0 ] . contractLogEvents , parsed . txs [ 0 ] . stxLockEvents ]
214
+ . flat ( )
215
+ . sort ( ( a , b ) => a . event_index - b . event_index ) ;
216
+ expect ( events ) . toHaveLength ( 13 ) ;
217
+ for ( let i = 0 ; i < events . length ; i ++ ) {
218
+ expect ( events [ i ] . event_index ) . toEqual ( i ) ;
219
+ }
220
+ // Ensure synthetic pox event indexes are in expected range
221
+ for ( const poxEvent of parsed . txs [ 0 ] . pox4Events ) {
222
+ expect ( poxEvent . event_index ) . toBeLessThan ( events . length ) ;
223
+ }
224
+ } ) ;
225
+
197
226
test ( 'test synthetic tx stx lock 2' , ( ) => {
198
227
// Testing a newer tx from mainnet (at block 51451)
199
228
const file =
0 commit comments