mirror of
https://github.com/go-i2p/go-i2p.git
synced 2025-07-04 21:55:18 -04:00
some build request record tests
This commit is contained in:
@ -230,7 +230,7 @@ func ReadBuildRequestRecord(data []byte) (BuildRequestRecord, error) {
|
|||||||
}
|
}
|
||||||
build_request_record.RequestTime = request_time
|
build_request_record.RequestTime = request_time
|
||||||
|
|
||||||
send_message_id, err := readBuildRequestRecordRequestSendMessageID(data)
|
send_message_id, err := readBuildRequestRecordSendMessageID(data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return build_request_record, err
|
return build_request_record, err
|
||||||
}
|
}
|
||||||
@ -389,7 +389,7 @@ func readBuildRequestRecordRequestTime(data []byte) (time.Time, error) {
|
|||||||
return rtime, nil
|
return rtime, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func readBuildRequestRecordRequestSendMessageID(data []byte) (int, error) {
|
func readBuildRequestRecordSendMessageID(data []byte) (int, error) {
|
||||||
if len(data) < 193 {
|
if len(data) < 193 {
|
||||||
return 0, ERR_BUILD_REQUEST_RECORD_NOT_ENOUGH_DATA
|
return 0, ERR_BUILD_REQUEST_RECORD_NOT_ENOUGH_DATA
|
||||||
}
|
}
|
||||||
|
@ -1 +1,72 @@
|
|||||||
package i2np
|
package i2np
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/hkparker/go-i2p/lib/common"
|
||||||
|
"github.com/hkparker/go-i2p/lib/tunnel"
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordReceiveTunnelTooLittleData(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
receive_tunnel, err := readBuildRequestRecordReceiveTunnel([]byte{0x01})
|
||||||
|
assert.Equal(tunnel.TunnelID(0), receive_tunnel)
|
||||||
|
assert.Equal(ERR_BUILD_REQUEST_RECORD_NOT_ENOUGH_DATA, err)
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordReceiveTunnelValidData(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
receive_tunnel, err := readBuildRequestRecordReceiveTunnel([]byte{0x00, 0x00, 0x00, 0x01})
|
||||||
|
assert.Equal(tunnel.TunnelID(1), receive_tunnel)
|
||||||
|
assert.Equal(nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordOurIdentTooLittleValidData(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
receive_tunnel := []byte{0x00, 0x00, 0x00, 0x01}
|
||||||
|
our_ident := make([]byte, 31)
|
||||||
|
our_ident[30] = 0x01
|
||||||
|
build_request_record := append(receive_tunnel, our_ident...)
|
||||||
|
read_ident, err := readBuildRequestRecordOurIdent(build_request_record)
|
||||||
|
hash := common.Hash{}
|
||||||
|
assert.Equal(hash, read_ident)
|
||||||
|
assert.Equal(ERR_BUILD_REQUEST_RECORD_NOT_ENOUGH_DATA, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordOurIdentValidData(t *testing.T) {
|
||||||
|
assert := assert.New(t)
|
||||||
|
|
||||||
|
receive_tunnel := []byte{0x00, 0x00, 0x00, 0x01}
|
||||||
|
our_ident := make([]byte, 32)
|
||||||
|
our_ident[31] = 0x01
|
||||||
|
build_request_record := append(receive_tunnel, our_ident...)
|
||||||
|
read_ident, err := readBuildRequestRecordOurIdent(build_request_record)
|
||||||
|
hash := common.Hash{}
|
||||||
|
copy(hash[:], our_ident)
|
||||||
|
assert.Equal(hash, read_ident)
|
||||||
|
assert.Equal(nil, err)
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordNextTunnel(t *testing.T) {}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordNextIdent(t *testing.T) {}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordLayerKey(t *testing.T) {}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordIVKey(t *testing.T) {}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordReplyKey(t *testing.T) {}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordReplyIV(t *testing.T) {}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordFlag(t *testing.T) {}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordRequestTime(t *testing.T) {}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordSendMessageID(t *testing.T) {}
|
||||||
|
|
||||||
|
func TestReadBuildRequestRecordPadding(t *testing.T) {}
|
||||||
|
Reference in New Issue
Block a user