@@ -71,18 +71,18 @@ func TestNat(t *testing.T) {
71
71
72
72
have := report .MakeReport ()
73
73
originalID := report .MakeEndpointNodeID ("host1" , "" , "10.0.47.1" , "80" )
74
- originalNode := report .MakeNodeWith (originalID , map [string ]string {
74
+ have . Endpoint . AddNode ( report .MakeNodeWith (originalID , map [string ]string {
75
75
"foo" : "bar" ,
76
- })
77
- have .Endpoint .AddNode (originalNode )
78
- fromID := report .MakeEndpointNodeID ("host2" , "" , "2.3.4.5" , "22223" )
76
+ }))
77
+ fromID := report .MakeEndpointNodeID ("host1" , "" , "2.3.4.5" , "22223" )
79
78
have .Endpoint .AddNode (report .MakeNodeWith (fromID , nil ).WithAdjacent (originalID ))
80
79
81
80
want := have .Copy ()
82
81
// add nat original destination as a copy of nat reply source
83
- origDstID := report .MakeEndpointNodeID ("host1" , "" , "1.2.3.4" , "80" )
84
- want .Endpoint .AddNode (originalNode . WithID ( origDstID ). WithLatests ( map [string ]string {
82
+ wantID := report .MakeEndpointNodeID ("host1" , "" , "1.2.3.4" , "80" )
83
+ want .Endpoint .AddNode (report . MakeNodeWith ( wantID , map [string ]string {
85
84
CopyOf : originalID ,
85
+ "foo" : "bar" ,
86
86
}))
87
87
88
88
makeNATMapper (ct ).applyNAT (have , "host1" )
@@ -91,7 +91,7 @@ func TestNat(t *testing.T) {
91
91
}
92
92
}
93
93
94
- // form the PoV of host2
94
+ // from the PoV of host2
95
95
{
96
96
f := conntrack.Conn {
97
97
MsgType : conntrack .NfctMsgUpdate ,
@@ -117,21 +117,21 @@ func TestNat(t *testing.T) {
117
117
}
118
118
119
119
have := report .MakeReport ()
120
- fromID := report .MakeEndpointNodeID ("host2" , "" , "10.0.47.2" , "22222" )
121
- toID := report .MakeEndpointNodeID ("host1 " , "" , "1.2.3.4" , "80" )
120
+ originalID := report .MakeEndpointNodeID ("host2" , "" , "10.0.47.2" , "22222" )
121
+ toID := report .MakeEndpointNodeID ("host2 " , "" , "1.2.3.4" , "80" )
122
122
have .Endpoint .AddNode (report .MakeNodeWith (toID , nil ))
123
- have .Endpoint .AddNode (report .MakeNodeWith (fromID , map [string ]string {
123
+ have .Endpoint .AddNode (report .MakeNodeWith (originalID , map [string ]string {
124
124
"foo" : "baz" ,
125
125
}).WithAdjacent (toID ))
126
126
127
127
// add NAT reply destination as a copy of NAT original source
128
128
want := have .Copy ()
129
129
want .Endpoint .AddNode (report .MakeNodeWith (report .MakeEndpointNodeID ("host2" , "" , "2.3.4.5" , "22223" ), map [string ]string {
130
- CopyOf : report . MakeEndpointNodeID ( "host1" , "" , "10.0.47.2" , "22222" ) ,
130
+ CopyOf : originalID ,
131
131
"foo" : "baz" ,
132
132
}).WithAdjacent (toID ))
133
133
134
- makeNATMapper (ct ).applyNAT (have , "host1 " )
134
+ makeNATMapper (ct ).applyNAT (have , "host2 " )
135
135
if ! reflect .DeepEqual (want , have ) {
136
136
t .Fatal (test .Diff (want , have ))
137
137
}
0 commit comments