@@ -25,8 +25,10 @@ import (
2525)
2626
2727func TestNetwork_OnNewConnection (t * testing.T ) {
28- host := proxytest .NewHostEmulator (nil , nil ,
29- newRootContext , newNetworkContext , nil )
28+ opt := proxytest .NewEmulatorOption ().
29+ WithNewStreamContext (newNetworkContext ).
30+ WithNewRootContext (newRootContext )
31+ host := proxytest .NewHostEmulator (opt )
3032 defer host .Done () // release the host emulation lock so that other test cases can insert their own host emulation
3133
3234 host .StartVM () // call OnVMStart: init metric
@@ -38,8 +40,10 @@ func TestNetwork_OnNewConnection(t *testing.T) {
3840}
3941
4042func TestNetwork_OnDownstreamClose (t * testing.T ) {
41- host := proxytest .NewHostEmulator (nil , nil ,
42- newRootContext , newNetworkContext , nil )
43+ opt := proxytest .NewEmulatorOption ().
44+ WithNewStreamContext (newNetworkContext ).
45+ WithNewRootContext (newRootContext )
46+ host := proxytest .NewHostEmulator (opt )
4347 defer host .Done () // release the host emulation lock so that other test cases can insert their own host emulation
4448
4549 contextID := host .NetworkFilterInitConnection () // OnNewConnection is called
@@ -51,8 +55,10 @@ func TestNetwork_OnDownstreamClose(t *testing.T) {
5155}
5256
5357func TestNetwork_OnDownstreamData (t * testing.T ) {
54- host := proxytest .NewHostEmulator (nil , nil ,
55- newRootContext , newNetworkContext , nil )
58+ opt := proxytest .NewEmulatorOption ().
59+ WithNewStreamContext (newNetworkContext ).
60+ WithNewRootContext (newRootContext )
61+ host := proxytest .NewHostEmulator (opt )
5662 defer host .Done () // release the host emulation lock so that other test cases can insert their own host emulation
5763
5864 contextID := host .NetworkFilterInitConnection () // OnNewConnection is called
@@ -66,8 +72,10 @@ func TestNetwork_OnDownstreamData(t *testing.T) {
6672}
6773
6874func TestNetwork_OnUpstreamData (t * testing.T ) {
69- host := proxytest .NewHostEmulator (nil , nil ,
70- newRootContext , newNetworkContext , nil )
75+ opt := proxytest .NewEmulatorOption ().
76+ WithNewStreamContext (newNetworkContext ).
77+ WithNewRootContext (newRootContext )
78+ host := proxytest .NewHostEmulator (opt )
7179 defer host .Done () // release the host emulation lock so that other test cases can insert their own host emulation
7280
7381 contextID := host .NetworkFilterInitConnection () // OnNewConnection is called
@@ -81,8 +89,10 @@ func TestNetwork_OnUpstreamData(t *testing.T) {
8189}
8290
8391func TestNetwork_counter (t * testing.T ) {
84- host := proxytest .NewHostEmulator (nil , nil ,
85- newRootContext , newNetworkContext , nil )
92+ opt := proxytest .NewEmulatorOption ().
93+ WithNewStreamContext (newNetworkContext ).
94+ WithNewRootContext (newRootContext )
95+ host := proxytest .NewHostEmulator (opt )
8696 defer host .Done () // release the host emulation lock so that other test cases can insert their own host emulation
8797
8898 host .StartVM () // call OnVMStart: init metric
0 commit comments