@@ -18,14 +18,18 @@ import (
1818)
1919
2020func OrdererOperationalClients (n * Network , o * Orderer ) (authClient , unauthClient * http.Client ) {
21- return operationalClients (n , n .OrdererLocalTLSDir (o ))
21+ return OrdererOperationalClientsTimeShift (n , o , 0 )
22+ }
23+
24+ func OrdererOperationalClientsTimeShift (n * Network , o * Orderer , timeShift time.Duration ) (authClient , unauthClient * http.Client ) {
25+ return operationalClients (n , n .OrdererLocalTLSDir (o ), timeShift )
2226}
2327
2428func PeerOperationalClients (n * Network , p * Peer ) (authClient , unauthClient * http.Client ) {
25- return operationalClients (n , n .PeerLocalTLSDir (p ))
29+ return operationalClients (n , n .PeerLocalTLSDir (p ), 0 )
2630}
2731
28- func operationalClients (n * Network , tlsDir string ) (authClient , unauthClient * http.Client ) {
32+ func operationalClients (n * Network , tlsDir string , timeShift time. Duration ) (authClient , unauthClient * http.Client ) {
2933 fingerprint := "http::" + tlsDir
3034 if d := n .throttleDuration (fingerprint ); d > 0 {
3135 time .Sleep (d )
@@ -42,19 +46,30 @@ func operationalClients(n *Network, tlsDir string) (authClient, unauthClient *ht
4246 Expect (err ).NotTo (HaveOccurred ())
4347 clientCertPool .AppendCertsFromPEM (caCert )
4448
49+ authenticatedTlsConfig := & tls.Config {
50+ Certificates : []tls.Certificate {clientCert },
51+ RootCAs : clientCertPool ,
52+ }
53+ unauthenticatedTlsConfig := & tls.Config {RootCAs : clientCertPool }
54+ if timeShift > 0 {
55+ authenticatedTlsConfig .Time = func () time.Time {
56+ return time .Now ().Add ((- 1 ) * timeShift )
57+ }
58+ unauthenticatedTlsConfig .Time = func () time.Time {
59+ return time .Now ().Add ((- 1 ) * timeShift )
60+ }
61+ }
62+
4563 authenticatedClient := & http.Client {
4664 Transport : & http.Transport {
4765 MaxIdleConnsPerHost : - 1 ,
48- TLSClientConfig : & tls.Config {
49- Certificates : []tls.Certificate {clientCert },
50- RootCAs : clientCertPool ,
51- },
66+ TLSClientConfig : authenticatedTlsConfig ,
5267 },
5368 }
5469 unauthenticatedClient := & http.Client {
5570 Transport : & http.Transport {
5671 MaxIdleConnsPerHost : - 1 ,
57- TLSClientConfig : & tls. Config { RootCAs : clientCertPool } ,
72+ TLSClientConfig : unauthenticatedTlsConfig ,
5873 },
5974 }
6075
0 commit comments