diff --git a/tests/BNS-V2.stateful.test.ts b/tests/BNS-V2.stateful.test.ts index a2ad0dd..cd1d56f 100644 --- a/tests/BNS-V2.stateful.test.ts +++ b/tests/BNS-V2.stateful.test.ts @@ -4,6 +4,7 @@ import { it } from "vitest"; import { GetLastTokenId } from "./state/GetLastTokenId.ts"; import { GetOwnerNone } from "./state/GetOwnerNone.ts"; import { GetBnsFromIdNone } from "./state/GetBnsFromIdNone.ts"; +import { GetPrimaryNameNone } from "./state/GetPrimaryNameNone.ts"; it("executes BNS-V2 state interactions", async () => { const excludedAccounts = ["faucet", "deployer"]; @@ -17,6 +18,7 @@ it("executes BNS-V2 state interactions", async () => { GetLastTokenId(filteredAccounts), GetOwnerNone(filteredAccounts), GetBnsFromIdNone(filteredAccounts), + GetPrimaryNameNone(filteredAccounts), ]; const model = { diff --git a/tests/state/GetPrimaryNameNone.ts b/tests/state/GetPrimaryNameNone.ts new file mode 100644 index 0000000..a7007e4 --- /dev/null +++ b/tests/state/GetPrimaryNameNone.ts @@ -0,0 +1,46 @@ +import fc from "fast-check"; +import { Model } from "./types"; +import { Simnet } from "@hirosystems/clarinet-sdk"; +import { expect } from "vitest"; +import { Cl } from "@stacks/transactions"; +import { prettyConsoleLog } from "../BNS-V2.helper"; + +export const GetPrimaryNameNone = (accounts: Map) => + fc + .record({ + sender: fc.constantFrom(...accounts), + owner: fc.constantFrom(...accounts), + }) + .map((r) => ({ + check: (model: Readonly) => { + const [, ownerAddress] = r.owner; + return !(Array.from(model.owners.values()).includes(ownerAddress)); + }, + run: (_model: Model, real: Simnet) => { + const [wallet, address] = r.sender; + const [ownerWallet, ownerAddress] = r.owner; + // Act + const { result: primaryNameOptional } = real.callReadOnlyFn( + "BNS-V2", + "get-primary-name", + [Cl.principal(ownerAddress)], + address, + ); + + // Assert + expect(primaryNameOptional).toBeNone(); + + prettyConsoleLog( + "Ӿ tx-sender", + wallet, + "✓", + "get-primary-name", + `owner: ${ownerWallet}`, + "primary-name: none", + ); + }, + toString: () => { + const [ownerWallet] = r.owner; + return `get-primary-name owner ${ownerWallet} primary-name none`; + }, + }));