nscript: load script view

This allows you to open and run scripts for testing purposes, but only
from external links such as nostr:nscript...
This commit is contained in:
William Casarin
2023-07-04 11:42:16 -07:00
parent 640fbf23ea
commit a04a401292
10 changed files with 261 additions and 25 deletions

View File

@@ -38,13 +38,13 @@ final class NostrScriptTests: XCTestCase {
func test_bool_set() throws {
var data = try load_bool_set_test_wasm().bytes
let pool = RelayPool()
let script = NostrScript(pool: pool)
let script = NostrScript(pool: pool, data: data)
let pk = "32e1827635450ebb3c5a7d12c1f8e7b2b514439ac10a67eef3d9fd9c5c68e245"
UserSettingsStore.pubkey = pk
let key = pk_setting_key(pk, key: "nozaps")
UserDefaults.standard.set(true, forKey: key)
let load_err = script.load(wasm: &data)
let load_err = script.load()
XCTAssertNil(load_err)
let res = script.run()
@@ -62,9 +62,9 @@ final class NostrScriptTests: XCTestCase {
func test_nostrscript() throws {
var data = try loadTestWasm().bytes
let pool = RelayPool()
let script = NostrScript(pool: pool)
let script = NostrScript(pool: pool, data: data)
let load_err = script.load(wasm: &data)
let load_err = script.load()
XCTAssertNil(load_err)
let res = script.run()