(t *testing.T)
| 89 | } |
| 90 | |
| 91 | func TestProposalKey(t *testing.T) { |
| 92 | id := uint64(2) |
| 93 | node := &node{Node: &conn.Node{Id: id}, ctx: context.Background(), closer: z.NewCloser(1)} |
| 94 | require.NoError(t, node.initProposalKey(node.Id)) |
| 95 | |
| 96 | pkey := proposalKey |
| 97 | nodeIdFromKey := proposalKey >> 48 |
| 98 | require.Equal(t, id, nodeIdFromKey, "id extracted from proposal key is not equal to initial value") |
| 99 | |
| 100 | valueOf48thBit := int(pkey & (1 << 48)) |
| 101 | require.Equal(t, 0, valueOf48thBit, "48th bit is not set to zero on initialisation") |
| 102 | |
| 103 | node.uniqueKey() |
| 104 | require.Equal(t, pkey+1, proposalKey, "proposal key should increment by 1 at each call of unique key") |
| 105 | |
| 106 | uniqueKeys := make(map[uint64]struct{}) |
| 107 | for i := 0; i < 10; i++ { |
| 108 | node.uniqueKey() |
| 109 | uniqueKeys[proposalKey] = struct{}{} |
| 110 | } |
| 111 | require.Equal(t, len(uniqueKeys), 10, "each iteration should create unique key") |
| 112 | } |
| 113 | |
| 114 | func TestZeroHealth(t *testing.T) { |
| 115 | client := http.Client{Timeout: 3 * time.Second} |
nothing calls this directly
no test coverage detected