-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
remote data fetching in remote and native, setting and cli params
- Loading branch information
1 parent
babbc1d
commit 0cf47fb
Showing
20 changed files
with
775 additions
and
264 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
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,11 @@ | ||
import request, { HttpVerb, Options as HttpOptions } from "sync-request"; | ||
|
||
const encoder = new TextEncoder(); | ||
|
||
export function httpClient(method: HttpVerb, path: string, options?: HttpOptions): Uint8Array { | ||
const response = request(method, path, options); | ||
if (typeof response.body === "string") { | ||
return encoder.encode(response.body); | ||
} | ||
return response.body; | ||
} |
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,43 @@ | ||
import fs from "node:fs"; | ||
import path from "node:path"; | ||
import { Cl } from "@stacks/transactions"; | ||
import { describe, expect, it, beforeEach, afterEach } from "vitest"; | ||
|
||
// test the built package and not the source code | ||
// makes it simpler to handle wasm build | ||
import { Simnet, getSDK, initSimnet, tx } from ".."; | ||
|
||
const deployerAddr = "ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM"; | ||
const address1 = "ST1SJ3DTE5DN7X54YDH5D64R3BCB6A2AG2ZQ8YPD5"; | ||
const address2 = "ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG"; | ||
|
||
let simnet: Simnet; | ||
|
||
const deploymentPlanPath = path.join( | ||
process.cwd(), | ||
"tests/fixtures/deployments/default.simnet-plan.yaml", | ||
); | ||
|
||
function deleteExistingDeploymentPlan() { | ||
if (fs.existsSync(deploymentPlanPath)) { | ||
fs.unlinkSync(deploymentPlanPath); | ||
} | ||
} | ||
|
||
beforeEach(async () => { | ||
deleteExistingDeploymentPlan(); | ||
simnet = await getSDK(); | ||
await simnet.initEmtpySession(); | ||
}); | ||
|
||
afterEach(() => { | ||
deleteExistingDeploymentPlan(); | ||
}); | ||
|
||
describe("simnet remote interactions", () => { | ||
it("can call a remote contract", () => { | ||
const r = simnet.execute("(+ 1 1)"); | ||
const result = simnet.callReadOnlyFn(`${address1}.counter2`, "one", [], address2); | ||
expect(result.result).toStrictEqual(Cl.int(2)); | ||
}); | ||
}); |
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
Oops, something went wrong.