add a test where the client offers chacha, but chacha is not avail in the server list: server preference should be honered if set
diff --git a/t/picotls.c b/t/picotls.c
index 467ea20..6116de0 100644
--- a/t/picotls.c
+++ b/t/picotls.c
@@ -102,6 +102,8 @@
ok(selected == &ptls_minicrypto_aes256gcmsha384);
ok(select_cipher(&selected, candidates, input, input + sizeof(input), 1, 1) == 0);
ok(selected == &ptls_minicrypto_chacha20poly1305sha256);
+ ok(select_cipher(&selected, candidates, input, input + sizeof(input), 0, 1) == 0);
+ ok(selected == &ptls_minicrypto_chacha20poly1305sha256);
}
{
@@ -113,6 +115,19 @@
ok(selected == &ptls_minicrypto_aes256gcmsha384);
}
+ {
+ ptls_cipher_suite_t *candidates[] = {&ptls_minicrypto_aes256gcmsha384, &ptls_minicrypto_aes128gcmsha256, NULL};
+ static const uint8_t input[] = {C(PTLS_CIPHER_SUITE_CHACHA20_POLY1305_SHA256), C(PTLS_CIPHER_SUITE_AES_128_GCM_SHA256), C(PTLS_CIPHER_SUITE_AES_256_GCM_SHA384)};
+ ok(select_cipher(&selected, candidates, input, input + sizeof(input), 1, 0) == 0);
+ ok(selected == &ptls_minicrypto_aes256gcmsha384);
+ ok(select_cipher(&selected, candidates, input, input + sizeof(input), 1, 1) == 0);
+ ok(selected == &ptls_minicrypto_aes256gcmsha384);
+ ok(select_cipher(&selected, candidates, input, input + sizeof(input), 0, 0) == 0);
+ ok(selected == &ptls_minicrypto_aes128gcmsha256);
+ ok(select_cipher(&selected, candidates, input, input + sizeof(input), 0, 1) == 0);
+ ok(selected == &ptls_minicrypto_aes128gcmsha256);
+ }
+
#undef C
}