mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-24 04:13:28 +01:00
Quick-and-dirty test for packed_cell_is_destroy
This commit is contained in:
parent
de3bbc4f53
commit
e198faa633
@ -8,7 +8,9 @@
|
||||
#define CONNECTION_EDGE_PRIVATE
|
||||
#define RELAY_PRIVATE
|
||||
#include "or.h"
|
||||
#include "channel.h"
|
||||
#include "connection_edge.h"
|
||||
#include "connection_or.h"
|
||||
#include "onion.h"
|
||||
#include "onion_tap.h"
|
||||
#include "onion_fast.h"
|
||||
@ -1212,6 +1214,47 @@ test_cfmt_resolved_cells(void *arg)
|
||||
#undef CLEAR_CELL
|
||||
}
|
||||
|
||||
static void
|
||||
test_cfmt_is_destroy(void *arg)
|
||||
{
|
||||
cell_t cell;
|
||||
packed_cell_t packed;
|
||||
circid_t circid = 0;
|
||||
channel_t *chan;
|
||||
(void)arg;
|
||||
|
||||
chan = tor_malloc_zero(sizeof(channel_t));
|
||||
|
||||
memset(&cell, 0xff, sizeof(cell));
|
||||
cell.circ_id = 3003;
|
||||
cell.command = CELL_RELAY;
|
||||
|
||||
cell_pack(&packed, &cell, 0);
|
||||
chan->wide_circ_ids = 0;
|
||||
tt_assert(! packed_cell_is_destroy(chan, &packed, &circid));
|
||||
tt_int_op(circid, ==, 0);
|
||||
|
||||
cell_pack(&packed, &cell, 1);
|
||||
chan->wide_circ_ids = 1;
|
||||
tt_assert(! packed_cell_is_destroy(chan, &packed, &circid));
|
||||
tt_int_op(circid, ==, 0);
|
||||
|
||||
cell.command = CELL_DESTROY;
|
||||
|
||||
cell_pack(&packed, &cell, 0);
|
||||
chan->wide_circ_ids = 0;
|
||||
tt_assert(packed_cell_is_destroy(chan, &packed, &circid));
|
||||
tt_int_op(circid, ==, 3003);
|
||||
|
||||
circid = 0;
|
||||
cell_pack(&packed, &cell, 1);
|
||||
chan->wide_circ_ids = 1;
|
||||
tt_assert(packed_cell_is_destroy(chan, &packed, &circid));
|
||||
|
||||
done:
|
||||
tor_free(chan);
|
||||
}
|
||||
|
||||
#define TEST(name, flags) \
|
||||
{ #name, test_cfmt_ ## name, flags, 0, NULL }
|
||||
|
||||
@ -1224,6 +1267,7 @@ struct testcase_t cell_format_tests[] = {
|
||||
TEST(extend_cells, 0),
|
||||
TEST(extended_cells, 0),
|
||||
TEST(resolved_cells, 0),
|
||||
TEST(is_destroy, 0),
|
||||
END_OF_TESTCASES
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user