summaryrefslogtreecommitdiffhomepage
path: root/packet
diff options
context:
space:
mode:
authorEiichiro Watanabe <a16tochjp@gmail.com>2015-12-09 12:26:14 +0900
committerEiichiro Watanabe <a16tochjp@gmail.com>2015-12-09 12:30:49 +0900
commitb963b94fbf3479ce670f5ef1c499a11c8fef1e0f (patch)
tree8a23e045dd8307b986bfa42ecc42c151a7e1fd37 /packet
parent86c92e09677875c027cf0aba9f15052b2becdadf (diff)
packet: add test examples for RTRErrorReport
Diffstat (limited to 'packet')
-rw-r--r--packet/rtr_test.go22
1 files changed, 18 insertions, 4 deletions
diff --git a/packet/rtr_test.go b/packet/rtr_test.go
index 3451b862..0f9b9527 100644
--- a/packet/rtr_test.go
+++ b/packet/rtr_test.go
@@ -102,7 +102,21 @@ func Test_RTRCacheReset(t *testing.T) {
verifyRTRMessage(t, NewRTRCacheReset())
}
-//TO BE IMPLEMENTED:
-//func Test_RTRErrorReport(t *testing.T) {
-// verifyRTRMessage(t, NewRTRErrorReport())
-//}
+func Test_RTRErrorReport(t *testing.T) {
+ errPDU, _ := NewRTRResetQuery().Serialize()
+ errText1 := []byte("Couldn't send CacheResponce PDU")
+ errText2 := []byte("Wrong Length of PDU: 10 bytes")
+
+ // See 5.10 ErrorReport in RFC6810
+ // when it doesn't have both "erroneous PDU" and "Arbitrary Text"
+ verifyRTRMessage(t, NewRTRErrorReport(NO_DATA_AVAILABLE, nil, nil))
+
+ // when it has "erroneous PDU"
+ verifyRTRMessage(t, NewRTRErrorReport(UNSUPPORTED_PROTOCOL_VERSION, errPDU, nil))
+
+ // when it has "ArbitaryText"
+ verifyRTRMessage(t, NewRTRErrorReport(INTERNAL_ERROR, nil, errText1))
+
+ // when it has both "erroneous PDU" and "Arbitrary Text"
+ verifyRTRMessage(t, NewRTRErrorReport(CORRUPT_DATA, errPDU, errText2))
+}