-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
181 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
Blockchain/Tests/BlockchainTests/VMInvocations/LogTests.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import Foundation | ||
import Testing | ||
import Utils | ||
|
||
@testable import Blockchain | ||
|
||
struct LogTests { | ||
@Test func testLogDetailJSON() async throws { | ||
let logDetials = Log.Details( | ||
time: "2023-04-01 12:00:00", | ||
level: .error, | ||
target: Data("target".utf8), | ||
message: Data("message".utf8), | ||
core: nil, | ||
service: 1 | ||
) | ||
let json = logDetials.json | ||
#expect(json["time"]?.string == "2023-04-01 12:00:00") | ||
#expect(json["level"]?.string == "ERROR") | ||
#expect(json["target"]?.string == "target") | ||
#expect(json["message"]?.string == "message") | ||
#expect(json["service"]?.string == "1") | ||
#expect(json["core"] == .null) | ||
} | ||
|
||
@Test func testLogDetailString() async throws { | ||
let logDetials = Log.Details( | ||
time: "2023-04-01 12:00:00", | ||
level: .trace, | ||
target: Data("target".utf8), | ||
message: Data("message".utf8), | ||
core: nil, | ||
service: nil | ||
) | ||
let str = logDetials.str | ||
#expect(str == "2023-04-01 12:00:00 TRACE target message") | ||
} | ||
|
||
@Test func testLogDetailInvalidString() async throws { | ||
let invalidData = Data([0xFF, 0xFE, 0xFD]) | ||
let logDetails = Log.Details( | ||
time: "2023-04-01 12:00:00", | ||
level: .warn, | ||
target: invalidData, | ||
message: invalidData, | ||
core: nil, | ||
service: nil | ||
) | ||
let str = logDetails.str | ||
#expect(str == "2023-04-01 12:00:00 WARN invalid string invalid string") | ||
} | ||
} |