MCPcopy Create free account
hub / github.com/ElementsProject/lightning / fuzz_exchange_commits

Function fuzz_exchange_commits

tests/fuzz/fuzz-full_channel.c:73–102  ·  view source on GitHub ↗

Randomize the commitment dance order. */

Source from the content-addressed store, hash-verified

71
72/* Randomize the commitment dance order. */
73static void fuzz_exchange_commits(struct channel *channel, const struct htlc ***changed_htlcs,
74 const u8 **cursor, size_t *max)
75{
76 int order[] = {0, 1, 2, 3};
77
78 /* Shuffle the call order using fuzzer data. */
79 for (size_t i = ARRAY_SIZE(order) - 1; i > 0 && *max > 0; i--) {
80 size_t j = fromwire_u8(cursor, max) % (i + 1);
81 int temp = order[i];
82 order[i] = order[j];
83 order[j] = temp;
84 }
85
86 for (size_t i = 0; i < ARRAY_SIZE(order); i++) {
87 switch (order[i]) {
88 case 0:
89 channel_sending_commit(channel, changed_htlcs);
90 break;
91 case 1:
92 channel_rcvd_revoke_and_ack(channel, changed_htlcs);
93 break;
94 case 2:
95 channel_rcvd_commit(channel, changed_htlcs);
96 break;
97 case 3:
98 channel_sending_revoke_and_ack(channel);
99 break;
100 }
101 }
102}
103
104static bool update_feerate(struct channel *channel, u32 feerate)
105{

Callers 1

runFunction · 0.85

Calls 5

channel_sending_commitFunction · 0.85
channel_rcvd_commitFunction · 0.85
fromwire_u8Function · 0.50

Tested by

no test coverage detected