Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions BitcoinSwiftTests/BitcoinDecodingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -129,14 +129,16 @@ class BitcoinDecodingTests: XCTestCase {

// Test reading a little-endian UInt64.
if let int = stream.readUInt64() {
XCTAssertEqual(int, UInt64(0x0807060504030201))
let varInt:UInt64 = 0x0807060504030201
XCTAssertEqual(int, varInt)
} else {
XCTFail("Failed to read int")
}

// Test reading a big-endian UInt64.
if let int = stream.readUInt64(.BigEndian) {
XCTAssertEqual(int, UInt64(0x090a0b0c0d0e0f10))
let varInt:UInt64 = 0x090a0b0c0d0e0f10
XCTAssertEqual(int, varInt)
} else {
XCTFail("Failed to read int")
}
Expand Down Expand Up @@ -362,7 +364,8 @@ class BitcoinDecodingTests: XCTestCase {
let stream = NSInputStream(data: data)
stream.open()
if let uint64 = stream.readVarInt() {
XCTAssertEqual(uint64, UInt64(0x0102030405060708))
let varInt:UInt64 = 0x0102030405060708
XCTAssertEqual(uint64, varInt)
} else {
XCTFail("Failed to read varint")
}
Expand Down
9 changes: 6 additions & 3 deletions BitcoinSwiftTests/BitcoinEncodingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,17 @@ class BitcoinEncodingTests: XCTestCase {

func testAppendUInt64LittleEndian() {
let data = NSMutableData()
data.appendUInt64(UInt64(0x0102030405060708))
let varInt:UInt64 = 0x0102030405060708
data.appendUInt64(varInt)
let expectedData = NSData(bytes: [0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01] as [UInt8],
length: 8)
XCTAssertEqual(data, expectedData)
}

func testAppendUInt64BigEndian() {
let data = NSMutableData()
data.appendUInt64(UInt64(0x0102030405060708), endianness: .BigEndian)
let varInt:UInt64 = 0x0102030405060708
data.appendUInt64(varInt, endianness: .BigEndian)
let expectedData = NSData(bytes: [0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08] as [UInt8],
length: 8)
XCTAssertEqual(data, expectedData)
Expand Down Expand Up @@ -139,7 +141,8 @@ class BitcoinEncodingTests: XCTestCase {

func testAppendVarIntUInt64() {
let data = NSMutableData()
data.appendVarInt(0x0100000000)
let varInt:UInt64 = 0x0100000000
data.appendVarInt(varInt)
let expectedData =
NSData(bytes: [0xff, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00] as [UInt8], length: 9)
XCTAssertEqual(data, expectedData)
Expand Down