@@ -44,16 +44,19 @@ describe('redis notifier', () => {
44
44
block_height : 1 ,
45
45
block_hash : '0x1234' ,
46
46
index_block_hash : '0x1234' ,
47
+ block_time : 1234 ,
47
48
} ) . build ( ) ;
48
49
await db . update ( block1 ) ;
49
50
50
51
expect ( messages . length ) . toBe ( 1 ) ;
51
- expect ( JSON . parse ( messages [ 0 ] ) . payload ) . toEqual ( {
52
- chain : 'stacks' ,
53
- network : 'mainnet' ,
54
- apply_blocks : [ { hash : '0x1234' , index : 1 } ] ,
55
- rollback_blocks : [ ] ,
56
- } ) ;
52
+ expect ( JSON . parse ( messages [ 0 ] ) . payload ) . toEqual (
53
+ expect . objectContaining ( {
54
+ chain : 'stacks' ,
55
+ network : 'mainnet' ,
56
+ apply_blocks : [ { hash : '0x1234' , index : 1 , time : 1234 } ] ,
57
+ rollback_blocks : [ ] ,
58
+ } )
59
+ ) ;
57
60
} ) ;
58
61
59
62
test ( 'updates redis with re-orgs' , async ( ) => {
@@ -62,31 +65,37 @@ describe('redis notifier', () => {
62
65
block_height : 1 ,
63
66
block_hash : '0x1234' ,
64
67
index_block_hash : '0x1234' ,
68
+ block_time : 1234 ,
65
69
} ) . build ( )
66
70
) ;
67
71
expect ( messages . length ) . toBe ( 1 ) ;
68
- expect ( JSON . parse ( messages [ 0 ] ) . payload ) . toEqual ( {
69
- chain : 'stacks' ,
70
- network : 'mainnet' ,
71
- apply_blocks : [ { hash : '0x1234' , index : 1 } ] ,
72
- rollback_blocks : [ ] ,
73
- } ) ;
72
+ expect ( JSON . parse ( messages [ 0 ] ) . payload ) . toEqual (
73
+ expect . objectContaining ( {
74
+ chain : 'stacks' ,
75
+ network : 'mainnet' ,
76
+ apply_blocks : [ { hash : '0x1234' , index : 1 , time : 1234 } ] ,
77
+ rollback_blocks : [ ] ,
78
+ } )
79
+ ) ;
74
80
75
81
await db . update (
76
82
new TestBlockBuilder ( {
77
83
block_height : 2 ,
78
84
block_hash : '0x1235' ,
79
85
index_block_hash : '0x1235' ,
80
86
parent_index_block_hash : '0x1234' ,
87
+ block_time : 1234 ,
81
88
} ) . build ( )
82
89
) ;
83
90
expect ( messages . length ) . toBe ( 2 ) ;
84
- expect ( JSON . parse ( messages [ 1 ] ) . payload ) . toEqual ( {
85
- chain : 'stacks' ,
86
- network : 'mainnet' ,
87
- apply_blocks : [ { hash : '0x1235' , index : 2 } ] ,
88
- rollback_blocks : [ ] ,
89
- } ) ;
91
+ expect ( JSON . parse ( messages [ 1 ] ) . payload ) . toEqual (
92
+ expect . objectContaining ( {
93
+ chain : 'stacks' ,
94
+ network : 'mainnet' ,
95
+ apply_blocks : [ { hash : '0x1235' , index : 2 , time : 1234 } ] ,
96
+ rollback_blocks : [ ] ,
97
+ } )
98
+ ) ;
90
99
91
100
// Re-org block 2, should not send a message because this block is not canonical
92
101
await db . update (
@@ -95,6 +104,7 @@ describe('redis notifier', () => {
95
104
block_hash : '0x1235aa' ,
96
105
index_block_hash : '0x1235aa' ,
97
106
parent_index_block_hash : '0x1234' ,
107
+ block_time : 1234 ,
98
108
} ) . build ( )
99
109
) ;
100
110
expect ( messages . length ) . toBe ( 2 ) ;
@@ -106,17 +116,20 @@ describe('redis notifier', () => {
106
116
block_hash : '0x1236' ,
107
117
index_block_hash : '0x1236' ,
108
118
parent_index_block_hash : '0x1235aa' ,
119
+ block_time : 1234 ,
109
120
} ) . build ( )
110
121
) ;
111
122
expect ( messages . length ) . toBe ( 3 ) ;
112
- expect ( JSON . parse ( messages [ 2 ] ) . payload ) . toEqual ( {
113
- chain : 'stacks' ,
114
- network : 'mainnet' ,
115
- apply_blocks : [
116
- { hash : '0x1235aa' , index : 2 } ,
117
- { hash : '0x1236' , index : 3 } ,
118
- ] ,
119
- rollback_blocks : [ { hash : '0x1235' , index : 2 } ] ,
120
- } ) ;
123
+ expect ( JSON . parse ( messages [ 2 ] ) . payload ) . toEqual (
124
+ expect . objectContaining ( {
125
+ chain : 'stacks' ,
126
+ network : 'mainnet' ,
127
+ apply_blocks : [
128
+ { hash : '0x1235aa' , index : 2 , time : 1234 } ,
129
+ { hash : '0x1236' , index : 3 , time : 1234 } ,
130
+ ] ,
131
+ rollback_blocks : [ { hash : '0x1235' , index : 2 , time : 1234 } ] ,
132
+ } )
133
+ ) ;
121
134
} ) ;
122
135
} ) ;
0 commit comments