-
Notifications
You must be signed in to change notification settings - Fork 11
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
86 additions
and
6 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
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,39 @@ | ||
import XCTest | ||
import SubstrateSdk | ||
|
||
final class RuntimeMetadataV15Tests: XCTestCase { | ||
func testPolkadotV15MetadataParsing() { | ||
performOpaqueV15MetadataTest(filename: "polkadot-v15") | ||
} | ||
|
||
private func performOpaqueV15MetadataTest(filename: String) { | ||
do { | ||
guard let url = Bundle(for: type(of: self)) | ||
.url(forResource: filename, withExtension: "") else { | ||
XCTFail("Can't find metadata file") | ||
return | ||
} | ||
|
||
let hex = try String(contentsOf: url) | ||
.trimmingCharacters(in: CharacterSet.whitespacesAndNewlines) | ||
let expectedData = try Data(hexString: hex) | ||
|
||
let runtimeMetadataContainer = try RuntimeMetadataContainer.createFromOpaque(data: expectedData) | ||
|
||
guard case .v15 = runtimeMetadataContainer.runtimeMetadata else { | ||
XCTFail("unexpected metadata") | ||
return | ||
} | ||
|
||
let encoder = ScaleEncoder() | ||
try runtimeMetadataContainer.encode(scaleEncoder: encoder) | ||
let resultData = encoder.encode() | ||
|
||
XCTAssertEqual(Data(expectedData.suffix(resultData.count)), resultData) | ||
|
||
UIPasteboard.general.string = resultData.toHex() | ||
} catch { | ||
XCTFail("Unexpected error: \(error)") | ||
} | ||
} | ||
} |