[DEV-31] Convert all timestamp to int64

This commit is contained in:
Ori Newman 2018-07-16 11:12:34 +03:00
parent d488aebe0d
commit 90b71f1bb7
6 changed files with 31 additions and 31 deletions

View File

@ -297,9 +297,9 @@ func BenchmarkDeserializeTxSmall(b *testing.B) {
0xe0, 0xa6, 0x04, 0xf8, 0x14, 0x17, 0x81, 0xe6,
0x22, 0x94, 0x72, 0x11, 0x66, 0xbf, 0x62, 0x1e,
0x73, 0xa8, 0x2c, 0xbf, 0x23, 0x42, 0xc8, 0x58,
0xee, // 65-byte signature
0xac, // OP_CHECKSIG
0x00, 0x00, 0x00, 0x00, // Lock time
0xee, // 65-byte signature
0xac, // OP_CHECKSIG
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
}
r := bytes.NewReader(buf)

View File

@ -229,43 +229,43 @@ func TestMerkleBlockWireErrors(t *testing.T) {
},
// Force error in difficulty bits.
{
&merkleBlockOne, merkleBlockOneBytes, pver, 72,
&merkleBlockOne, merkleBlockOneBytes, pver, 76,
io.ErrShortWrite, io.EOF,
},
// Force error in header nonce.
{
&merkleBlockOne, merkleBlockOneBytes, pver, 76,
&merkleBlockOne, merkleBlockOneBytes, pver, 80,
io.ErrShortWrite, io.EOF,
},
// Force error in transaction count.
{
&merkleBlockOne, merkleBlockOneBytes, pver, 80,
&merkleBlockOne, merkleBlockOneBytes, pver, 84,
io.ErrShortWrite, io.EOF,
},
// Force error in num hashes.
{
&merkleBlockOne, merkleBlockOneBytes, pver, 84,
&merkleBlockOne, merkleBlockOneBytes, pver, 88,
io.ErrShortWrite, io.EOF,
},
// Force error in hashes.
{
&merkleBlockOne, merkleBlockOneBytes, pver, 85,
&merkleBlockOne, merkleBlockOneBytes, pver, 89,
io.ErrShortWrite, io.EOF,
},
// Force error in num flag bytes.
{
&merkleBlockOne, merkleBlockOneBytes, pver, 117,
&merkleBlockOne, merkleBlockOneBytes, pver, 121,
io.ErrShortWrite, io.EOF,
},
// Force error in flag bytes.
{
&merkleBlockOne, merkleBlockOneBytes, pver, 118,
&merkleBlockOne, merkleBlockOneBytes, pver, 122,
io.ErrShortWrite, io.EOF,
},
// Force error due to unsupported protocol version.
{
&merkleBlockOne, merkleBlockOneBytes, pverNoMerkleBlock,
119, wireErr, wireErr,
123, wireErr, wireErr,
},
}
@ -326,7 +326,7 @@ func TestMerkleBlockOverflowErrors(t *testing.T) {
// allowed tx hashes.
var buf bytes.Buffer
WriteVarInt(&buf, pver, maxTxPerBlock+1)
numHashesOffset := 84
numHashesOffset := 88
exceedMaxHashes := make([]byte, numHashesOffset)
copy(exceedMaxHashes, merkleBlockOneBytes[:numHashesOffset])
exceedMaxHashes = append(exceedMaxHashes, buf.Bytes()...)
@ -335,7 +335,7 @@ func TestMerkleBlockOverflowErrors(t *testing.T) {
// allowed flag bytes.
buf.Reset()
WriteVarInt(&buf, pver, maxFlagsPerMerkleBlock+1)
numFlagBytesOffset := 117
numFlagBytesOffset := 121
exceedMaxFlagBytes := make([]byte, numFlagBytesOffset)
copy(exceedMaxFlagBytes, merkleBlockOneBytes[:numFlagBytesOffset])
exceedMaxFlagBytes = append(exceedMaxFlagBytes, buf.Bytes()...)

View File

@ -181,9 +181,9 @@ func TestTxWire(t *testing.T) {
noTx.Version = 1
noTxEncoded := []byte{
0x01, 0x00, 0x00, 0x00, // Version
0x00, // Varint for number of input transactions
0x00, // Varint for number of output transactions
0x00, 0x00, 0x00, 0x00, // Lock time
0x00, // Varint for number of input transactions
0x00, // Varint for number of output transactions
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
}
tests := []struct {
@ -374,9 +374,9 @@ func TestTxSerialize(t *testing.T) {
noTx.Version = 1
noTxEncoded := []byte{
0x01, 0x00, 0x00, 0x00, // Version
0x00, // Varint for number of input transactions
0x00, // Varint for number of output transactions
0x00, 0x00, 0x00, 0x00, // Lock time
0x00, // Varint for number of input transactions
0x00, // Varint for number of output transactions
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
}
tests := []struct {
@ -619,10 +619,10 @@ func TestTxSerializeSize(t *testing.T) {
size int // Expected serialized size
}{
// No inputs or outpus.
{noTx, 10},
{noTx, 14},
// Transcaction with an input and an output.
{multiTx, 210},
{multiTx, 214},
}
t.Logf("Running %d tests", len(tests))
@ -726,9 +726,9 @@ var multiTxEncoded = []byte{
0x3d, 0x81, 0xb0, 0x1c, 0xc3, 0x1f, 0x04, 0x78,
0x34, 0xbc, 0x06, 0xd6, 0xd6, 0xed, 0xf6, 0x20,
0xd1, 0x84, 0x24, 0x1a, 0x6a, 0xed, 0x8b, 0x63,
0xa6, // 65-byte signature
0xac, // OP_CHECKSIG
0x00, 0x00, 0x00, 0x00, // Lock time
0xa6, // 65-byte signature
0xac, // OP_CHECKSIG
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // Lock time
}
// multiTxPkScriptLocs is the location information for the public key scripts

View File

@ -209,7 +209,7 @@ func (msg *MsgVersion) Command() string {
func (msg *MsgVersion) MaxPayloadLength(pver uint32) uint32 {
// XXX: <= 106 different
// Protocol version 4 bytes + services 8 bytes + timestamp 8 bytes +
// Protocol version 4 bytes + services 8 bytes + timestamp 16 bytes +
// remote and local net addresses + nonce 8 bytes + length of user
// agent (varInt) + max allowed useragent length + last block 4 bytes +
// relay transactions flag 1 byte.

View File

@ -103,11 +103,11 @@ func TestVersion(t *testing.T) {
}
// Ensure max payload is expected value.
// Protocol version 4 bytes + services 8 bytes + timestamp 8 bytes +
// Protocol version 4 bytes + services 8 bytes + timestamp 16 bytes +
// remote and local net addresses + nonce 8 bytes + length of user agent
// (varInt) + max allowed user agent length + last block 4 bytes +
// relay transactions flag 1 byte.
wantPayload := uint32(358)
wantPayload := uint32(366)
maxPayload := msg.MaxPayloadLength(pver)
if maxPayload != wantPayload {
t.Errorf("MaxPayloadLength: wrong max payload length for "+

View File

@ -51,7 +51,7 @@ func TestNetAddress(t *testing.T) {
// Ensure max payload is expected value for latest protocol version.
pver := ProtocolVersion
wantPayload := uint32(30)
wantPayload := uint32(34)
maxPayload := maxNetAddressPayload(ProtocolVersion)
if maxPayload != wantPayload {
t.Errorf("maxNetAddressPayload: wrong max payload length for "+
@ -228,11 +228,11 @@ func TestNetAddressWireErrors(t *testing.T) {
// Force errors on timestamp.
{&baseNetAddr, []byte{}, pver, true, 0, io.ErrShortWrite, io.EOF},
// Force errors on services.
{&baseNetAddr, []byte{}, pver, true, 4, io.ErrShortWrite, io.EOF},
{&baseNetAddr, []byte{}, pver, true, 8, io.ErrShortWrite, io.EOF},
// Force errors on ip.
{&baseNetAddr, []byte{}, pver, true, 12, io.ErrShortWrite, io.EOF},
{&baseNetAddr, []byte{}, pver, true, 16, io.ErrShortWrite, io.EOF},
// Force errors on port.
{&baseNetAddr, []byte{}, pver, true, 28, io.ErrShortWrite, io.EOF},
{&baseNetAddr, []byte{}, pver, true, 32, io.ErrShortWrite, io.EOF},
// Latest protocol version with no timestamp and intentional
// read/write errors.