AtlatestRepositorysigil-quic
sigil-quic / tree / testtest-network-confirmation.sgl
1
(import (sigil test)2
(sigil quic bytes)3
(sigil quic frame)4
(sigil quic connection network))6
(define (nc-with-passive procedure)7
(let ((network8
(make-connection-network #u8(1) #u8(2) 'server #u8(10) 09
(list (cons 0 #u8(10 11 12 13 14 15 16 17)) (cons 15 #u8(1)))10
(list (cons 15 #u8(2))) confirmed?: #f)))11
(dynamic-wind12
(lambda () #t)13
(lambda () (procedure network))14
(lambda () (network-close! network)))))16
(define (nc-advertisement)17
(make-quic-frame 2418
(list (cons 'sequence 1) (cons 'retire-prior-to 0)19
(cons 'connection-id #u8(3)) (cons 'token (make-bytevector 16 0)))))21
(test-group "Passive CID ownership before handshake confirmation"22
(test "network-confirmation: early CID metadata is retained while every path operation is refused"23
(nc-with-passive24
(lambda (network)25
(assert-true (network-peer-id! network (nc-advertisement)))26
(for-each27
(lambda (procedure) (assert-error (procedure)))28
(list29
(lambda () (network-observe! network #u8(11) 1200 1 (list (make-quic-frame 1 '())) 0))30
(lambda () (network-challenge! network #u8(11) 0))31
(lambda () (network-reserve-send! network #u8(10) 1200 0))32
(lambda () (network-response! network (make-bytevector 8 0) 0))33
(lambda () (network-tick! network 0))))34
(assert-true35
(and (bytes=? #u8(10) (network-address network))36
(not (network-candidate network)) (not (network-destination network #u8(11)))37
(null? (network-take-events! network)))))))38
(test "network-confirmation: confirmation seeds ordering once and preserves early CID ownership"39
(nc-with-passive40
(lambda (network)41
(network-peer-id! network (nc-advertisement))42
(network-confirm! network 100 10)43
(assert-true44
(and (not (network-observe! network #u8(11) 1200 9 (list (make-quic-frame 1 '())) 100))45
(network-observe! network #u8(11) 1200 11 (list (make-quic-frame 1 '())) 100)46
(let ((probe (network-challenge! network #u8(11) 100)))47
(and probe (= 1 (vector-ref probe 1))48
(bytes=? #u8(3) (vector-ref probe 2))49
(network-response! network (vector-ref probe 3) 101)50
(network-confirm! network 102 0)51
(bytes=? #u8(11) (network-address network))52
(not (network-observe! network #u8(12) 1200 10 (list (make-quic-frame 1 '())) 102)))))))))53
(test "network-confirmation: close-route snapshots are owned and exclude uncommitted or retired IDs"54
(nc-with-passive55
(lambda (network)56
(let ((frame (network-issue-id! network #u8(4) (make-bytevector 16 0))))57
(assert-false (network-local-id network 1))58
(network-commit-id! network frame)59
(let ((copy (network-local-id network 1)))60
(bytevector-u8-set! copy 0 5))61
(assert-true62
(and (bytes=? #u8(4) (network-local-id network 1))63
(network-retire-local-id! network 1 #u8(1))64
(not (network-local-id network 1))65
(bytes=? #u8(1) (network-local-id network 0)))))))))