Skip to content

Commit

Permalink
Fixing unit-tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
juagargi committed Dec 3, 2024
1 parent a8b4deb commit 3e2dd6c
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion router/dataplane_hbird.go
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ func (p *scionPacketProcessor) checkReservationBandwidth() (processResult, error
panic("tokenbucket map contains value of different type")
}

if tb.Apply(int(p.scionLayer.PayloadLen), time.Now()) {
if tb.Apply(int(p.scionLayer.PayloadLen), now) {
return processResult{}, nil
}
// TODO: return scmp packet for reservation overuse
Expand Down
10 changes: 5 additions & 5 deletions router/dataplane_hbird_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ func TestProcessHbirdPacket(t *testing.T) {
dpath.HopFields[2].HopField)
ret := toMsg(t, spkt, dpath)
if afterProcessing {
ret.Addr = &net.UDPAddr{IP: dst.IP().AsSlice(), Port: topology.EndhostPort}
ret.Addr = &net.UDPAddr{IP: dst.IP().AsSlice(), Port: dstUDPPort}
ret.Flags, ret.NN, ret.N, ret.OOB = 0, 0, 0, nil

}
Expand Down Expand Up @@ -659,7 +659,7 @@ func TestProcessHbirdPacket(t *testing.T) {
dpath.HopFields[2].HopField.Mac = computeMAC(t, key, dpath.InfoFields[0],
dpath.HopFields[2].HopField)
ret := toMsg(t, spkt, dpath)
ret.Addr = &net.UDPAddr{IP: dst.IP().AsSlice(), Port: topology.EndhostPort}
ret.Addr = &net.UDPAddr{IP: dst.IP().AsSlice(), Port: dstUDPPort}
ret.Flags, ret.NN, ret.N, ret.OOB = 0, 0, 0, nil
return ret
}
Expand Down Expand Up @@ -735,7 +735,7 @@ func TestProcessHbirdPacket(t *testing.T) {
spkt.PayloadLen, dpath.InfoFields[0], dpath.HopFields[2], dpath.PathMeta)
ret := toMsg(t, spkt, dpath)
if afterProcessing {
ret.Addr = &net.UDPAddr{IP: dst.IP().AsSlice(), Port: topology.EndhostPort}
ret.Addr = &net.UDPAddr{IP: dst.IP().AsSlice(), Port: dstUDPPort}
ret.Flags, ret.NN, ret.N, ret.OOB = 0, 0, 0, nil
}
return ret
Expand Down Expand Up @@ -3838,7 +3838,7 @@ func prepHbirdMsg(now time.Time) (*slayers.SCION, *hummingbird.Decoded) {
DstIA: xtest.MustParseIA("4-ff00:0:411"),
SrcIA: xtest.MustParseIA("2-ff00:0:222"),
Path: &hummingbird.Raw{},
PayloadLen: 18,
PayloadLen: 26, // scionudpLayer + len("actualpayloadbytes")
}

dpath := &hummingbird.Decoded{
Expand Down Expand Up @@ -3871,7 +3871,7 @@ func prepHbirdSlayers(src, dst addr.IA) *slayers.SCION {
DstIA: dst,
SrcIA: src,
Path: &hummingbird.Raw{},
PayloadLen: 18,
PayloadLen: 26, // scionudpLayer + len("actualpayloadbytes")
}
return spkt
}
Expand Down
3 changes: 3 additions & 0 deletions router/dataplane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,7 @@ func TestDataPlaneRun(t *testing.T) {

_ = ret.SetIA(local)
_ = ret.SetKey(key)
_ = ret.SetHbirdKey(key)
return ret
},
},
Expand Down Expand Up @@ -686,6 +687,7 @@ func TestDataPlaneRun(t *testing.T) {

_ = ret.SetIA(local)
_ = ret.SetKey(key)
_ = ret.SetHbirdKey(key)

nextHopAddr := xtest.MustParseUDPAddr(t, "127.0.0.2:8888")
err = ret.AddNextHop(2, l.Addr, nextHopAddr, nobfd, "")
Expand Down Expand Up @@ -915,6 +917,7 @@ func TestDataPlaneRun(t *testing.T) {

_ = ret.SetIA(local)
_ = ret.SetKey(key)
_ = ret.SetHbirdKey(key)

nextHopAddr := xtest.MustParseUDPAddr(t, "127.0.0.2:8888")
err = ret.AddNextHop(2, l.Addr, nextHopAddr, nobfd, "")
Expand Down

0 comments on commit 3e2dd6c

Please sign in to comment.