(node_factory, bitcoind, executor, benchmark)
| 135 | |
| 136 | |
| 137 | def test_generate_coinmoves(node_factory, bitcoind, executor, benchmark): |
| 138 | l1, l2, l3 = get_bench_line_graph(node_factory, 3, wait_for_announce=True) |
| 139 | |
| 140 | # Route some payments |
| 141 | l1.rpc.xpay(l3.rpc.invoice(1, "test_generate_coinmoves", "test_generate_coinmoves")['bolt11']) |
| 142 | # Make some payments |
| 143 | l2.rpc.xpay(l3.rpc.invoice(1, "test_generate_coinmoves3", "test_generate_coinmoves3")['bolt11']) |
| 144 | # Receive some payments |
| 145 | l1.rpc.xpay(l2.rpc.invoice(1, "test_generate_coinmoves", "test_generate_coinmoves")['bolt11']) |
| 146 | wait_for(lambda: all([c['htlcs'] == [] for c in l1.rpc.listpeerchannels()['channels']])) |
| 147 | |
| 148 | l2.stop() |
| 149 | entries = l2.db.query('SELECT * FROM channel_moves ORDER BY id;') |
| 150 | assert len(entries) == 4 |
| 151 | next_id = entries[-1]['id'] + 1 |
| 152 | next_timestamp = entries[-1]['timestamp'] + 1 |
| 153 | |
| 154 | batch = [] |
| 155 | # Let's make 5 million entries. |
| 156 | for _ in range(5_000_000 // len(entries)): |
| 157 | # Random payment_hash |
| 158 | entries[0]['payment_hash'] = entries[1]['payment_hash'] = random.randbytes(32) |
| 159 | entries[2]['payment_hash'] = random.randbytes(32) |
| 160 | entries[3]['payment_hash'] = random.randbytes(32) |
| 161 | # Incrementing timestamps |
| 162 | for e in entries: |
| 163 | e['timestamp'] = next_timestamp |
| 164 | next_timestamp += 1 |
| 165 | |
| 166 | for e in entries: |
| 167 | batch.append(( |
| 168 | next_id, |
| 169 | e['account_channel_id'], |
| 170 | e['account_nonchannel_id'], |
| 171 | e['tag_bitmap'], |
| 172 | e['credit_or_debit'], |
| 173 | e['timestamp'], |
| 174 | e['payment_hash'], |
| 175 | e['payment_part_id'], |
| 176 | e['payment_group_id'], |
| 177 | e['fees'], |
| 178 | )) |
| 179 | next_id += 1 |
| 180 | |
| 181 | l2.db.executemany("INSERT INTO channel_moves" |
| 182 | " (id, account_channel_id, account_nonchannel_id, tag_bitmap, credit_or_debit," |
| 183 | " timestamp, payment_hash, payment_part_id, payment_group_id, fees)" |
| 184 | " VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", |
| 185 | batch) |
| 186 | l2.start() |
| 187 | |
| 188 | def measure_latency(node, stop_event): |
| 189 | latencies = [] |
| 190 | |
| 191 | while not stop_event.is_set(): |
| 192 | time.sleep(0.1) |
| 193 | |
| 194 | start = time.time() |
nothing calls this directly
no test coverage detected