From d42a8732734991df21850f92cdd5216da2878c8a Mon Sep 17 00:00:00 2001 From: rmgaray Date: Tue, 7 Jan 2025 10:33:57 -0300 Subject: [PATCH 1/6] generate coverage report with serialization tests --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index be8e2e8..3ed6549 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ ], "scripts": { "test": "npm run test-serialization ; npm run test-api", - "test-serialization": "NODE_OPTIONS=--experimental-vm-modules jest tests/serialization/serialization.test.ts", + "test-serialization": "NODE_OPTIONS=--experimental-vm-modules jest tests/serialization/serialization.test.ts --coverage --collectCoverageFrom=\"src/**/*.ts\"", "test-serialization-dev": "NODE_OPTIONS=--experimental-vm-modules jest tests/serialization/serialization_dev.test.ts", "test-api": "npm run generate-cdl-definitions ; NODE_OPTIONS=--experimental-vm-modules jest tests/api/api.test.ts", "test-implementation": "NODE_OPTIONS=--experimental-vm-modules jest fees hash min_output_ada private_key bip32-ed25519", From 6d80fb890e05ce4ac0e14071ea30b341d80f86da Mon Sep 17 00:00:00 2001 From: rmgaray Date: Mon, 13 Jan 2025 11:02:53 -0300 Subject: [PATCH 2/6] add pure-rand library --- package-lock.json | 5 ++--- package.json | 3 ++- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 825b0cb..306bb19 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,6 +14,7 @@ "@noble/hashes": "^1.5.0", "base58-js": "^2.0.0", "bech32": "^2.0.0", + "pure-rand": "^6.1.0", "tweetnacl": "^1.0.3" }, "devDependencies": { @@ -5114,7 +5115,6 @@ "version": "6.1.0", "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.1.0.tgz", "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==", - "dev": true, "funding": [ { "type": "individual", @@ -10618,8 +10618,7 @@ "pure-rand": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-6.1.0.tgz", - "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==", - "dev": true + "integrity": "sha512-bVWawvoZoBYpp6yIoQtQXHZjmz35RSVHnUOTefl8Vcjr8snTPY1wnpSPMWekcFwbxI6gtmT7rSYPFvz71ldiOA==" }, "queue-microtask": { "version": "1.2.3", diff --git a/package.json b/package.json index 3ed6549..e1293c8 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "@noble/hashes": "^1.5.0", "bech32": "^2.0.0", "base58-js": "^2.0.0", - "tweetnacl": "^1.0.3" + "tweetnacl": "^1.0.3", + "pure-rand": "^6.1.0" } } From eb62431ab78b161f2b984804c79bdb2d5913524c Mon Sep 17 00:00:00 2001 From: rmgaray Date: Mon, 13 Jan 2025 15:27:01 -0300 Subject: [PATCH 3/6] add custom arbitrary instance for BigNum --- conway-cddl/yaml/custom/bignum.yaml | 7 +++++++ src/generated.ts | 9 +++++++++ 2 files changed, 16 insertions(+) diff --git a/conway-cddl/yaml/custom/bignum.yaml b/conway-cddl/yaml/custom/bignum.yaml index 68df3c1..cb1a81e 100644 --- a/conway-cddl/yaml/custom/bignum.yaml +++ b/conway-cddl/yaml/custom/bignum.yaml @@ -6,6 +6,8 @@ BigNum: value: min: 0n max: BigNum._maxU64() + methods: + arbitrary: null extra_methods: | // Lifted from: https://doc.rust-lang.org/std/primitive.u64.html#associatedconstant.MAX static _maxU64(): bigint { @@ -71,6 +73,11 @@ BigNum: return this.toJsValue() < rhs_value.toJsValue(); } + static arbitrary(prng: RandomGenerator): BigNum { + const n: bigint = prand.uniformBigIntDistribution(0n, BigNum._maxU64(), prng)[0] + return new BigNum(n); + } + static max_value(): BigNum { return new BigNum(BigNum._maxU64()); } diff --git a/src/generated.ts b/src/generated.ts index ee50421..57b8716 100644 --- a/src/generated.ts +++ b/src/generated.ts @@ -1418,6 +1418,15 @@ export class BigNum { return this.toJsValue() < rhs_value.toJsValue(); } + static arbitrary(prng: RandomGenerator): BigNum { + const n: bigint = prand.uniformBigIntDistribution( + 0n, + BigNum._maxU64(), + prng, + )[0]; + return new BigNum(n); + } + static max_value(): BigNum { return new BigNum(BigNum._maxU64()); } From 4a7679a5aedaacfc81b9956fea0aace064213e87 Mon Sep 17 00:00:00 2001 From: rmgaray Date: Mon, 13 Jan 2025 15:28:47 -0300 Subject: [PATCH 4/6] add arbitrary to CodeGeneratorBase & support arbitrary in proper arrays --- conway-cddl/codegen/generators/array.ts | 17 + conway-cddl/codegen/generators/index.ts | 19 + conway-cddl/codegen/main.ts | 2 + src/generated.ts | 845 ++++++++++++++++++++++++ 4 files changed, 883 insertions(+) diff --git a/conway-cddl/codegen/generators/array.ts b/conway-cddl/codegen/generators/array.ts index 95fd8bb..7fdd02b 100644 --- a/conway-cddl/codegen/generators/array.ts +++ b/conway-cddl/codegen/generators/array.ts @@ -103,4 +103,21 @@ export class GenArray extends CodeGeneratorBase { ` } } + + generateArbitrary(prng: string): string { + if (this.item) { + return ` + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new ${this.name}([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(${this.itemJsType()}.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + `; + } else { + return `throw new Error("Not Implemented")`; + } + } } diff --git a/conway-cddl/codegen/generators/index.ts b/conway-cddl/codegen/generators/index.ts index 5701f45..0445f3c 100644 --- a/conway-cddl/codegen/generators/index.ts +++ b/conway-cddl/codegen/generators/index.ts @@ -37,6 +37,10 @@ export class CodeGeneratorBase { return contents != null ? contents(newName) : newName; } + arbitrary(seed: string): string { + return `${this.name}.arbitrary(${seed})`; + } + deserialize(reader: string, path: string): string { return `${this.name}.deserialize(${reader}, ${path})`; } @@ -124,6 +128,10 @@ export class CodeGeneratorBase { return ""; } + generateArbitrary(_prng: string): string { + return `throw new Error("Not Implemented")`; + } + generateDeserialize(_reader: string, _path: string): string { return `throw new Error("Not Implemented");`; } @@ -217,6 +225,16 @@ export class CodeGeneratorBase { `; } + let arbitrary: string = ` + ${this.renameMethod( + "arbitrary", + (arbitrary) => ` + static ${arbitrary}(prng: RandomGenerator): ${this.name} { + ${this.generateArbitrary("prng")} + }` + )} + ` + return ` ${this.generatePre()} @@ -228,6 +246,7 @@ export class CodeGeneratorBase { ${deserialize} ${serialize} + ${arbitrary} ${this.options.genCSL ? this.generateCSLHelpers() : ""} diff --git a/conway-cddl/codegen/main.ts b/conway-cddl/codegen/main.ts index f648bd7..96cfee4 100644 --- a/conway-cddl/codegen/main.ts +++ b/conway-cddl/codegen/main.ts @@ -85,6 +85,8 @@ async function main() { // @ts-expect-error: Assigning Node.js webcrypto to globalThis.crypto globalThis.crypto = webcrypto; } + import { RandomGenerator } from 'pure-rand'; + import prand from 'pure-rand'; function $$UN(id: string, ...args: any): any { throw ("Undefined function: " + id); diff --git a/src/generated.ts b/src/generated.ts index 57b8716..d8bd608 100644 --- a/src/generated.ts +++ b/src/generated.ts @@ -14,6 +14,8 @@ if (typeof globalThis.crypto === "undefined") { // @ts-expect-error: Assigning Node.js webcrypto to globalThis.crypto globalThis.crypto = webcrypto; } +import { RandomGenerator } from "pure-rand"; +import prand from "pure-rand"; function $$UN(id: string, ...args: any): any { throw "Undefined function: " + id; @@ -84,6 +86,10 @@ export class Anchor { this._anchor_data_hash.serialize(writer); } + static arbitrary(prng: RandomGenerator): Anchor { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -178,6 +184,10 @@ export class AnchorDataHash { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): AnchorDataHash { + throw new Error("Not Implemented"); + } } export class AssetName { @@ -205,6 +215,10 @@ export class AssetName { writer.writeBytes(this.inner); } + static arbitrary(prng: RandomGenerator): AssetName { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -277,6 +291,17 @@ export class AssetNames { ); } + static arbitrary(prng: RandomGenerator): AssetNames { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new AssetNames([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(AssetName.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -378,6 +403,10 @@ export class Assets { }); } + static arbitrary(prng: RandomGenerator): Assets { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -580,6 +609,10 @@ export class AuxiliaryData { } } + static arbitrary(prng: RandomGenerator): AuxiliaryData { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -865,6 +898,10 @@ export class AuxiliaryDataHash { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): AuxiliaryDataHash { + throw new Error("Not Implemented"); + } } export class AuxiliaryDataPostAlonzo { @@ -1053,6 +1090,10 @@ export class AuxiliaryDataPostAlonzo { } } + static arbitrary(prng: RandomGenerator): AuxiliaryDataPostAlonzo { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -1144,6 +1185,10 @@ export class AuxiliaryDataSet { }); } + static arbitrary(prng: RandomGenerator): AuxiliaryDataSet { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -1269,6 +1314,10 @@ export class AuxiliaryDataShelleyMa { this._auxiliary_scripts.serialize(writer); } + static arbitrary(prng: RandomGenerator): AuxiliaryDataShelleyMa { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -1477,6 +1526,10 @@ export class Bip32PrivateKey { writer.writeBytes(this.inner); } + static arbitrary(prng: RandomGenerator): Bip32PrivateKey { + throw new Error("Not Implemented"); + } + static _LEN = 96; static _BECH32_HRP = "xprv"; @@ -1625,6 +1678,10 @@ export class Bip32PublicKey { writer.writeBytes(this.inner); } + static arbitrary(prng: RandomGenerator): Bip32PublicKey { + throw new Error("Not Implemented"); + } + static _LEN = 64; static _BECH32_HRP = "xpub"; @@ -1807,6 +1864,10 @@ export class Block { this._inner_invalid_transactions.serialize(writer); } + static arbitrary(prng: RandomGenerator): Block { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -1927,6 +1988,10 @@ export class BlockHash { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): BlockHash { + throw new Error("Not Implemented"); + } } export class BootstrapWitness { @@ -2026,6 +2091,10 @@ export class BootstrapWitness { writer.writeBytes(this._attributes); } + static arbitrary(prng: RandomGenerator): BootstrapWitness { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -2136,6 +2205,10 @@ export class BootstrapWitnesses { ); } + static arbitrary(prng: RandomGenerator): BootstrapWitnesses { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -2184,6 +2257,10 @@ export class CSLBigInt { return this.inner; } + static arbitrary(prng: RandomGenerator): CSLBigInt { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -2926,6 +3003,10 @@ export class Certificate { } } + static arbitrary(prng: RandomGenerator): Certificate { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -3033,6 +3114,10 @@ export class Certificates { ); } + static arbitrary(prng: RandomGenerator): Certificates { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -3155,6 +3240,10 @@ export class ChangeConfig { } } + static arbitrary(prng: RandomGenerator): ChangeConfig { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -3287,6 +3376,10 @@ export class CommitteeColdResign { } } + static arbitrary(prng: RandomGenerator): CommitteeColdResign { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -3392,6 +3485,10 @@ export class CommitteeEpochs { }); } + static arbitrary(prng: RandomGenerator): CommitteeEpochs { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -3485,6 +3582,10 @@ export class CommitteeHotAuth { this._committee_hot_credential.serialize(writer); } + static arbitrary(prng: RandomGenerator): CommitteeHotAuth { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -3581,6 +3682,10 @@ export class Constitution { } } + static arbitrary(prng: RandomGenerator): Constitution { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -3686,6 +3791,10 @@ export class ConstrPlutusData { this._data.serialize(writer); } + static arbitrary(prng: RandomGenerator): ConstrPlutusData { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -3796,6 +3905,17 @@ export class CostModel { ); } + static arbitrary(prng: RandomGenerator): CostModel { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new CostModel([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(Int.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -3911,6 +4031,10 @@ export class Costmdls { }); } + static arbitrary(prng: RandomGenerator): Costmdls { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -4025,6 +4149,10 @@ export class Credentials { ); } + static arbitrary(prng: RandomGenerator): Credentials { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -4083,6 +4211,10 @@ export class DNSRecordAorAAAA { writer.writeString(this.inner); } + static arbitrary(prng: RandomGenerator): DNSRecordAorAAAA { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -4141,6 +4273,10 @@ export class DNSRecordSRV { writer.writeString(this.inner); } + static arbitrary(prng: RandomGenerator): DNSRecordSRV { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -4309,6 +4445,10 @@ export class DRep { } } + static arbitrary(prng: RandomGenerator): DRep { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -4381,6 +4521,10 @@ export class DRepDeregistration { this._coin.serialize(writer); } + static arbitrary(prng: RandomGenerator): DRepDeregistration { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -4480,6 +4624,10 @@ export class DRepRegistration { } } + static arbitrary(prng: RandomGenerator): DRepRegistration { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -4573,6 +4721,10 @@ export class DRepUpdate { } } + static arbitrary(prng: RandomGenerator): DRepUpdate { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -4879,6 +5031,10 @@ export class DRepVotingThresholds { this._treasury_withdrawal.serialize(writer); } + static arbitrary(prng: RandomGenerator): DRepVotingThresholds { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -4952,6 +5108,10 @@ export class Data { writer.writeBytes(this.inner); } + static arbitrary(prng: RandomGenerator): Data { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -5024,6 +5184,10 @@ export class DataCost { this._coins_per_byte.serialize(writer); } + static arbitrary(prng: RandomGenerator): DataCost { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -5118,6 +5282,10 @@ export class DataHash { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): DataHash { + throw new Error("Not Implemented"); + } } export enum DataOptionKind { @@ -5216,6 +5384,10 @@ export class DataOption { } } + static arbitrary(prng: RandomGenerator): DataOption { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -5348,6 +5520,10 @@ export class DatumSource { } } + static arbitrary(prng: RandomGenerator): DatumSource { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -5452,6 +5628,10 @@ export class Ed25519KeyHash { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): Ed25519KeyHash { + throw new Error("Not Implemented"); + } } export class Ed25519KeyHashes { @@ -5528,6 +5708,10 @@ export class Ed25519KeyHashes { ); } + static arbitrary(prng: RandomGenerator): Ed25519KeyHashes { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -5604,6 +5788,10 @@ export class Ed25519Signature { writer.writeBytes(this.inner); } + static arbitrary(prng: RandomGenerator): Ed25519Signature { + throw new Error("Not Implemented"); + } + static _BECH32_HRP = "ed25519_sig"; static from_bech32(bech_str: string): Ed25519Signature { let decoded = bech32.decode(bech_str, Number.MAX_SAFE_INTEGER); @@ -5686,6 +5874,10 @@ export class ExUnitPrices { this._step_price.serialize(writer); } + static arbitrary(prng: RandomGenerator): ExUnitPrices { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -5778,6 +5970,10 @@ export class ExUnits { this._steps.serialize(writer); } + static arbitrary(prng: RandomGenerator): ExUnits { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -5882,6 +6078,10 @@ export class GeneralTransactionMetadata { }); } + static arbitrary(prng: RandomGenerator): GeneralTransactionMetadata { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -5982,6 +6182,10 @@ export class GenesisDelegateHash { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): GenesisDelegateHash { + throw new Error("Not Implemented"); + } } export class GenesisHash { @@ -6051,6 +6255,10 @@ export class GenesisHash { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): GenesisHash { + throw new Error("Not Implemented"); + } } export class GenesisHashes { @@ -6096,6 +6304,17 @@ export class GenesisHashes { ); } + static arbitrary(prng: RandomGenerator): GenesisHashes { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new GenesisHashes([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(GenesisHash.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -6395,6 +6614,10 @@ export class GovernanceAction { } } + static arbitrary(prng: RandomGenerator): GovernanceAction { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -6490,6 +6713,10 @@ export class GovernanceActionId { writer.writeInt(BigInt(this._index)); } + static arbitrary(prng: RandomGenerator): GovernanceActionId { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -6566,6 +6793,17 @@ export class GovernanceActionIds { ); } + static arbitrary(prng: RandomGenerator): GovernanceActionIds { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new GovernanceActionIds([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(GovernanceActionId.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -6676,6 +6914,10 @@ export class GovernanceActions { }); } + static arbitrary(prng: RandomGenerator): GovernanceActions { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -6771,6 +7013,10 @@ export class HardForkInitiationAction { this._protocol_version.serialize(writer); } + static arbitrary(prng: RandomGenerator): HardForkInitiationAction { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -6867,6 +7113,10 @@ export class Header { this._body_signature.serialize(writer); } + static arbitrary(prng: RandomGenerator): Header { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -7129,6 +7379,10 @@ export class HeaderBody { this._protocol_version.serialize(writer); } + static arbitrary(prng: RandomGenerator): HeaderBody { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -7205,6 +7459,10 @@ export class InfoAction { serialize(writer: CBORWriter): void {} + static arbitrary(prng: RandomGenerator): InfoAction { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -7257,6 +7515,10 @@ export class Int { writer.writeInt(this.inner); } + static arbitrary(prng: RandomGenerator): Int { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -7375,6 +7637,10 @@ export class InvalidTransactions { ); } + static arbitrary(prng: RandomGenerator): InvalidTransactions { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -7437,6 +7703,10 @@ export class Ipv4 { writer.writeBytes(this.inner); } + static arbitrary(prng: RandomGenerator): Ipv4 { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -7489,6 +7759,10 @@ export class Ipv6 { writer.writeBytes(this.inner); } + static arbitrary(prng: RandomGenerator): Ipv6 { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -7541,6 +7815,10 @@ export class KESSignature { writer.writeBytes(this.inner); } + static arbitrary(prng: RandomGenerator): KESSignature { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -7641,6 +7919,10 @@ export class KESVKey { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): KESVKey { + throw new Error("Not Implemented"); + } } export enum LanguageKind { @@ -7691,6 +7973,10 @@ export class Language { writer.writeInt(BigInt(this.kind_)); } + static arbitrary(prng: RandomGenerator): Language { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -7760,6 +8046,17 @@ export class Languages { ); } + static arbitrary(prng: RandomGenerator): Languages { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new Languages([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(Language.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -7841,6 +8138,17 @@ export class MetadataList { ); } + static arbitrary(prng: RandomGenerator): MetadataList { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new MetadataList([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(TransactionMetadatum.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -7951,6 +8259,10 @@ export class MetadataMap { }); } + static arbitrary(prng: RandomGenerator): MetadataMap { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -8080,6 +8392,10 @@ export class Mint { }); } + static arbitrary(prng: RandomGenerator): Mint { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -8231,6 +8547,10 @@ export class MintAssets { }); } + static arbitrary(prng: RandomGenerator): MintAssets { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -8306,6 +8626,17 @@ export class MintsAssets { ); } + static arbitrary(prng: RandomGenerator): MintsAssets { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new MintsAssets([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(MintAssets.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -8407,6 +8738,10 @@ export class MultiAsset { }); } + static arbitrary(prng: RandomGenerator): MultiAsset { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -8557,6 +8892,10 @@ export class MultiHostName { this._dns_name.serialize(writer); } + static arbitrary(prng: RandomGenerator): MultiHostName { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -8793,6 +9132,10 @@ export class NativeScript { } } + static arbitrary(prng: RandomGenerator): NativeScript { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -8916,6 +9259,10 @@ export class NativeScriptRefInput { writer.writeInt(BigInt(this._script_size)); } + static arbitrary(prng: RandomGenerator): NativeScriptRefInput { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -9048,6 +9395,10 @@ export class NativeScriptSource { } } + static arbitrary(prng: RandomGenerator): NativeScriptSource { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -9175,6 +9526,10 @@ export class NativeScripts { ); } + static arbitrary(prng: RandomGenerator): NativeScripts { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -9250,6 +9605,10 @@ export class NetworkId { writer.writeInt(BigInt(this.kind_)); } + static arbitrary(prng: RandomGenerator): NetworkId { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -9342,6 +9701,10 @@ export class NewConstitutionAction { this._constitution.serialize(writer); } + static arbitrary(prng: RandomGenerator): NewConstitutionAction { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -9416,6 +9779,10 @@ export class NoConfidenceAction { } } + static arbitrary(prng: RandomGenerator): NoConfidenceAction { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -9503,6 +9870,10 @@ export class Nonce { } } + static arbitrary(prng: RandomGenerator): Nonce { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -9637,6 +10008,10 @@ export class OperationalCert { this._sigma.serialize(writer); } + static arbitrary(prng: RandomGenerator): OperationalCert { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -9766,6 +10141,10 @@ export class OutputDatum { } } + static arbitrary(prng: RandomGenerator): OutputDatum { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -9894,6 +10273,10 @@ export class ParameterChangeAction { } } + static arbitrary(prng: RandomGenerator): ParameterChangeAction { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -10131,6 +10514,10 @@ export class PlutusData { } } + static arbitrary(prng: RandomGenerator): PlutusData { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -10229,6 +10616,17 @@ export class PlutusList { ); } + static arbitrary(prng: RandomGenerator): PlutusList { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new PlutusList([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(PlutusData.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -10338,6 +10736,10 @@ export class PlutusMap { }); } + static arbitrary(prng: RandomGenerator): PlutusMap { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -10433,6 +10835,17 @@ export class PlutusMapValues { ); } + static arbitrary(prng: RandomGenerator): PlutusMapValues { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new PlutusMapValues([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(PlutusData.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -10489,6 +10902,10 @@ export class PlutusScript { writer.writeBytes(this.inner); } + static arbitrary(prng: RandomGenerator): PlutusScript { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -10604,6 +11021,10 @@ export class PlutusScripts { ); } + static arbitrary(prng: RandomGenerator): PlutusScripts { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -10711,6 +11132,10 @@ export class PlutusSet { ); } + static arbitrary(prng: RandomGenerator): PlutusSet { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -10810,6 +11235,10 @@ export class PoolMetadata { this._pool_metadata_hash.serialize(writer); } + static arbitrary(prng: RandomGenerator): PoolMetadata { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -10910,6 +11339,10 @@ export class PoolMetadataHash { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): PoolMetadataHash { + throw new Error("Not Implemented"); + } } export class PoolParams { @@ -11099,6 +11532,10 @@ export class PoolParams { } } + static arbitrary(prng: RandomGenerator): PoolParams { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -11160,6 +11597,10 @@ export class PoolRegistration { this._pool_params.serialize(writer); } + static arbitrary(prng: RandomGenerator): PoolRegistration { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -11238,6 +11679,10 @@ export class PoolRetirement { writer.writeInt(BigInt(this._epoch)); } + static arbitrary(prng: RandomGenerator): PoolRetirement { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -11425,6 +11870,10 @@ export class PoolVotingThresholds { this._security_relevant_threshold.serialize(writer); } + static arbitrary(prng: RandomGenerator): PoolVotingThresholds { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -11601,6 +12050,10 @@ export class PostAlonzoTransactionOutput { } } + static arbitrary(prng: RandomGenerator): PostAlonzoTransactionOutput { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -11727,6 +12180,10 @@ export class PreBabbageTransactionOutput { } } + static arbitrary(prng: RandomGenerator): PreBabbageTransactionOutput { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -11789,6 +12246,10 @@ export class PrivateKey { writer.writeBytes(this.inner); } + static arbitrary(prng: RandomGenerator): PrivateKey { + throw new Error("Not Implemented"); + } + static _KEY_LEN = 32; static _EXT_KEY_LEN = 64; static _BECH32_HRP = "ed25519_sk"; @@ -11965,6 +12426,10 @@ export class ProposedProtocolParameterUpdates { }); } + static arbitrary(prng: RandomGenerator): ProposedProtocolParameterUpdates { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -12808,6 +13273,10 @@ export class ProtocolParamUpdate { } } + static arbitrary(prng: RandomGenerator): ProtocolParamUpdate { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -12935,6 +13404,10 @@ export class ProtocolVersion { writer.writeInt(BigInt(this._minor)); } + static arbitrary(prng: RandomGenerator): ProtocolVersion { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -13011,6 +13484,10 @@ export class PublicKey { writer.writeBytes(this.inner); } + static arbitrary(prng: RandomGenerator): PublicKey { + throw new Error("Not Implemented"); + } + static _BECH32_HRP = "ed25519_pk"; hash(): Ed25519KeyHash { @@ -13062,6 +13539,10 @@ export class Redeemer { this.inner.serialize(writer); } + static arbitrary(prng: RandomGenerator): Redeemer { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -13164,6 +13645,10 @@ export class RedeemerTag { writer.writeInt(BigInt(this.kind_)); } + static arbitrary(prng: RandomGenerator): RedeemerTag { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -13285,6 +13770,10 @@ export class Redeemers { } } + static arbitrary(prng: RandomGenerator): Redeemers { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -13430,6 +13919,17 @@ export class RedeemersArray { ); } + static arbitrary(prng: RandomGenerator): RedeemersArray { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new RedeemersArray([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(RedeemersArrayItem.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -13560,6 +14060,10 @@ export class RedeemersArrayItem { this._ex_units.serialize(writer); } + static arbitrary(prng: RandomGenerator): RedeemersArrayItem { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -13652,6 +14156,10 @@ export class RedeemersKey { this._index.serialize(writer); } + static arbitrary(prng: RandomGenerator): RedeemersKey { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -13728,6 +14236,17 @@ export class RedeemersKeys { ); } + static arbitrary(prng: RandomGenerator): RedeemersKeys { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new RedeemersKeys([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(RedeemersKey.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -13832,6 +14351,10 @@ export class RedeemersMap { }); } + static arbitrary(prng: RandomGenerator): RedeemersMap { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -13924,6 +14447,10 @@ export class RedeemersValue { this._ex_units.serialize(writer); } + static arbitrary(prng: RandomGenerator): RedeemersValue { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -14002,6 +14529,10 @@ export class RegCert { this._coin.serialize(writer); } + static arbitrary(prng: RandomGenerator): RegCert { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -14153,6 +14684,10 @@ export class Relay { } } + static arbitrary(prng: RandomGenerator): Relay { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -14222,6 +14757,17 @@ export class Relays { ); } + static arbitrary(prng: RandomGenerator): Relays { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new Relays([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(Relay.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -14292,6 +14838,17 @@ export class RewardAddresses { ); } + static arbitrary(prng: RandomGenerator): RewardAddresses { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new RewardAddresses([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(RewardAddress.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -14357,6 +14914,10 @@ export class ScriptAll { this._native_scripts.serialize(writer); } + static arbitrary(prng: RandomGenerator): ScriptAll { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -14419,6 +14980,10 @@ export class ScriptAny { this._native_scripts.serialize(writer); } + static arbitrary(prng: RandomGenerator): ScriptAny { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -14516,6 +15081,10 @@ export class ScriptDataHash { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): ScriptDataHash { + throw new Error("Not Implemented"); + } } export class ScriptHash { @@ -14585,6 +15154,10 @@ export class ScriptHash { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): ScriptHash { + throw new Error("Not Implemented"); + } } export class ScriptHashes { @@ -14629,6 +15202,17 @@ export class ScriptHashes { ); } + static arbitrary(prng: RandomGenerator): ScriptHashes { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new ScriptHashes([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(ScriptHash.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -14707,6 +15291,10 @@ export class ScriptNOfK { this._native_scripts.serialize(writer); } + static arbitrary(prng: RandomGenerator): ScriptNOfK { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -14763,6 +15351,10 @@ export class ScriptPubkey { this.inner.serialize(writer); } + static arbitrary(prng: RandomGenerator): ScriptPubkey { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -14828,6 +15420,10 @@ export class ScriptPubname { this._addr_keyhash.serialize(writer); } + static arbitrary(prng: RandomGenerator): ScriptPubname { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -15009,6 +15605,10 @@ export class ScriptRef { } } + static arbitrary(prng: RandomGenerator): ScriptRef { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -15149,6 +15749,10 @@ export class SingleHostAddr { } } + static arbitrary(prng: RandomGenerator): SingleHostAddr { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -15230,6 +15834,10 @@ export class SingleHostName { this._dns_name.serialize(writer); } + static arbitrary(prng: RandomGenerator): SingleHostName { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -15335,6 +15943,10 @@ export class StakeAndVoteDelegation { this._drep.serialize(writer); } + static arbitrary(prng: RandomGenerator): StakeAndVoteDelegation { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -15416,6 +16028,10 @@ export class StakeDelegation { this._pool_keyhash.serialize(writer); } + static arbitrary(prng: RandomGenerator): StakeDelegation { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -15481,6 +16097,10 @@ export class StakeDeregistration { this._stake_credential.serialize(writer); } + static arbitrary(prng: RandomGenerator): StakeDeregistration { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -15546,6 +16166,10 @@ export class StakeRegistration { this._stake_credential.serialize(writer); } + static arbitrary(prng: RandomGenerator): StakeRegistration { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -15659,6 +16283,10 @@ export class StakeRegistrationAndDelegation { this._coin.serialize(writer); } + static arbitrary(prng: RandomGenerator): StakeRegistrationAndDelegation { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -15789,6 +16417,10 @@ export class StakeVoteRegistrationAndDelegation { this._coin.serialize(writer); } + static arbitrary(prng: RandomGenerator): StakeVoteRegistrationAndDelegation { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -15854,6 +16486,10 @@ export class TimelockExpiry { this._slot.serialize(writer); } + static arbitrary(prng: RandomGenerator): TimelockExpiry { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -15924,6 +16560,10 @@ export class TimelockStart { this._slot.serialize(writer); } + static arbitrary(prng: RandomGenerator): TimelockStart { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -16064,6 +16704,10 @@ export class Transaction { } } + static arbitrary(prng: RandomGenerator): Transaction { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -16152,6 +16796,17 @@ export class TransactionBodies { ); } + static arbitrary(prng: RandomGenerator): TransactionBodies { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new TransactionBodies([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(TransactionBody.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -16721,6 +17376,10 @@ export class TransactionBody { } } + static arbitrary(prng: RandomGenerator): TransactionBody { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -16879,6 +17538,10 @@ export class TransactionHash { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): TransactionHash { + throw new Error("Not Implemented"); + } } export class TransactionInput { @@ -16943,6 +17606,10 @@ export class TransactionInput { writer.writeInt(BigInt(this._index)); } + static arbitrary(prng: RandomGenerator): TransactionInput { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -17053,6 +17720,10 @@ export class TransactionInputs { ); } + static arbitrary(prng: RandomGenerator): TransactionInputs { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -17238,6 +17909,10 @@ export class TransactionMetadatum { } } + static arbitrary(prng: RandomGenerator): TransactionMetadatum { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -17316,6 +17991,17 @@ export class TransactionMetadatumLabels { ); } + static arbitrary(prng: RandomGenerator): TransactionMetadatumLabels { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new TransactionMetadatumLabels([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(BigNum.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -17447,6 +18133,10 @@ export class TransactionOutput { } } + static arbitrary(prng: RandomGenerator): TransactionOutput { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -17643,6 +18333,17 @@ export class TransactionOutputs { ); } + static arbitrary(prng: RandomGenerator): TransactionOutputs { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new TransactionOutputs([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(TransactionOutput.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -17738,6 +18439,10 @@ export class TransactionUnspentOutput { this._output.serialize(writer); } + static arbitrary(prng: RandomGenerator): TransactionUnspentOutput { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -17820,6 +18525,17 @@ export class TransactionUnspentOutputs { ); } + static arbitrary(prng: RandomGenerator): TransactionUnspentOutputs { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new TransactionUnspentOutputs([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(TransactionUnspentOutput.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -18078,6 +18794,10 @@ export class TransactionWitnessSet { } } + static arbitrary(prng: RandomGenerator): TransactionWitnessSet { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -18181,6 +18901,17 @@ export class TransactionWitnessSets { ); } + static arbitrary(prng: RandomGenerator): TransactionWitnessSets { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new TransactionWitnessSets([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(TransactionWitnessSet.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -18282,6 +19013,10 @@ export class TreasuryWithdrawals { }); } + static arbitrary(prng: RandomGenerator): TreasuryWithdrawals { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -18377,6 +19112,10 @@ export class TreasuryWithdrawalsAction { } } + static arbitrary(prng: RandomGenerator): TreasuryWithdrawalsAction { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -18440,6 +19179,10 @@ export class URL { writer.writeString(this.inner); } + static arbitrary(prng: RandomGenerator): URL { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -18546,6 +19289,10 @@ export class UnitInterval { this._denominator.serialize(writer); } + static arbitrary(prng: RandomGenerator): UnitInterval { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -18624,6 +19371,10 @@ export class UnregCert { this._coin.serialize(writer); } + static arbitrary(prng: RandomGenerator): UnregCert { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -18730,6 +19481,10 @@ export class Update { writer.writeInt(BigInt(this._epoch)); } + static arbitrary(prng: RandomGenerator): Update { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -18808,6 +19563,10 @@ export class UpdateCommitteeAction { this._members_to_remove = members_to_remove; } + static arbitrary(prng: RandomGenerator): UpdateCommitteeAction { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -18944,6 +19703,10 @@ export class VRFCert { writer.writeBytes(this._proof); } + static arbitrary(prng: RandomGenerator): VRFCert { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -19038,6 +19801,10 @@ export class VRFKeyHash { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): VRFKeyHash { + throw new Error("Not Implemented"); + } } export class VRFVKey { @@ -19107,6 +19874,10 @@ export class VRFVKey { serialize(writer: CBORWriter): void { writer.writeBytes(this.inner); } + + static arbitrary(prng: RandomGenerator): VRFVKey { + throw new Error("Not Implemented"); + } } export class Value { @@ -19176,6 +19947,10 @@ export class Value { } } + static arbitrary(prng: RandomGenerator): Value { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -19306,6 +20081,10 @@ export class Vkey { this._public_key = public_key; } + static arbitrary(prng: RandomGenerator): Vkey { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -19385,6 +20164,17 @@ export class Vkeys { ); } + static arbitrary(prng: RandomGenerator): Vkeys { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new Vkeys([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(Vkey.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -19471,6 +20261,10 @@ export class Vkeywitness { this._signature.serialize(writer); } + static arbitrary(prng: RandomGenerator): Vkeywitness { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -19578,6 +20372,10 @@ export class Vkeywitnesses { ); } + static arbitrary(prng: RandomGenerator): Vkeywitnesses { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -19656,6 +20454,10 @@ export class VoteDelegation { this._drep.serialize(writer); } + static arbitrary(prng: RandomGenerator): VoteDelegation { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -19778,6 +20580,10 @@ export class VoteRegistrationAndDelegation { this._coin.serialize(writer); } + static arbitrary(prng: RandomGenerator): VoteRegistrationAndDelegation { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -20003,6 +20809,10 @@ export class Voter { } } + static arbitrary(prng: RandomGenerator): Voter { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -20134,6 +20944,17 @@ export class Voters { ); } + static arbitrary(prng: RandomGenerator): Voters { + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let ret = new Voters([], isDefinite > 0); + for (let _i = 0; _i < len; _i++) { + ret.add(Voter.arbitrary(prng_mut)); + prand.unsafeSkipN(prng_mut, 1); + } + return ret; + } + // no-op free(): void {} @@ -20226,6 +21047,10 @@ export class VotingProcedure { } } + static arbitrary(prng: RandomGenerator): VotingProcedure { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -20334,6 +21159,10 @@ export class VotingProcedures { }); } + static arbitrary(prng: RandomGenerator): VotingProcedures { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -20498,6 +21327,10 @@ export class VotingProposal { this._anchor.serialize(writer); } + static arbitrary(prng: RandomGenerator): VotingProposal { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -20619,6 +21452,10 @@ export class VotingProposals { ); } + static arbitrary(prng: RandomGenerator): VotingProposals { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -20720,6 +21557,10 @@ export class Withdrawals { }); } + static arbitrary(prng: RandomGenerator): Withdrawals { + throw new Error("Not Implemented"); + } + // no-op free(): void {} @@ -20827,6 +21668,10 @@ export class certificates { ); } + static arbitrary(prng: RandomGenerator): certificates { + throw new Error("Not Implemented"); + } + // no-op free(): void {} From 05e316a3d5d17c8db528a79cfcc71a576568da5b Mon Sep 17 00:00:00 2001 From: rmgaray Date: Mon, 13 Jan 2025 15:56:58 -0300 Subject: [PATCH 5/6] support arbitrary in Uint32Arrays --- conway-cddl/codegen/generators/array.ts | 21 ++++++---- src/generated.ts | 51 ++++++++++++++----------- 2 files changed, 42 insertions(+), 30 deletions(-) diff --git a/conway-cddl/codegen/generators/array.ts b/conway-cddl/codegen/generators/array.ts index 7fdd02b..b5148a0 100644 --- a/conway-cddl/codegen/generators/array.ts +++ b/conway-cddl/codegen/generators/array.ts @@ -105,19 +105,24 @@ export class GenArray extends CodeGeneratorBase { } generateArbitrary(prng: string): string { - if (this.item) { return ` let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); - let ret = new ${this.name}([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { - ret.add(${this.itemJsType()}.arbitrary(prng_mut)); + ${this.item ? + `let ret = new ${this.name}([], isDefinite > 0);` : + `let items = new Uint32Array(len);` + } + for (let i = 0; i < len; i++) { + ${this.item ? + `ret.add(${this.itemJsType()}.arbitrary(prng_mut));` : + `items[i] = prand.unsafeUniformIntDistribution(0, 4294967295, prng_mut);` + } prand.unsafeSkipN(prng_mut, 1); } - return ret; + ${this.item ? + `return ret;` : + `return new ${this.name}(items, isDefinite > 0);` + } `; - } else { - return `throw new Error("Not Implemented")`; - } } } diff --git a/src/generated.ts b/src/generated.ts index d8bd608..f6ceb0b 100644 --- a/src/generated.ts +++ b/src/generated.ts @@ -295,7 +295,7 @@ export class AssetNames { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new AssetNames([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(AssetName.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -3909,7 +3909,7 @@ export class CostModel { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new CostModel([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(Int.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -6308,7 +6308,7 @@ export class GenesisHashes { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new GenesisHashes([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(GenesisHash.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -6797,7 +6797,7 @@ export class GovernanceActionIds { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new GovernanceActionIds([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(GovernanceActionId.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -7638,7 +7638,14 @@ export class InvalidTransactions { } static arbitrary(prng: RandomGenerator): InvalidTransactions { - throw new Error("Not Implemented"); + let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); + let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); + let items = new Uint32Array(len); + for (let i = 0; i < len; i++) { + items[i] = prand.unsafeUniformIntDistribution(0, 4294967295, prng_mut); + prand.unsafeSkipN(prng_mut, 1); + } + return new InvalidTransactions(items, isDefinite > 0); } // no-op @@ -8050,7 +8057,7 @@ export class Languages { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new Languages([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(Language.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -8142,7 +8149,7 @@ export class MetadataList { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new MetadataList([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(TransactionMetadatum.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -8630,7 +8637,7 @@ export class MintsAssets { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new MintsAssets([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(MintAssets.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -10620,7 +10627,7 @@ export class PlutusList { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new PlutusList([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(PlutusData.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -10839,7 +10846,7 @@ export class PlutusMapValues { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new PlutusMapValues([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(PlutusData.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -13923,7 +13930,7 @@ export class RedeemersArray { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new RedeemersArray([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(RedeemersArrayItem.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -14240,7 +14247,7 @@ export class RedeemersKeys { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new RedeemersKeys([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(RedeemersKey.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -14761,7 +14768,7 @@ export class Relays { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new Relays([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(Relay.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -14842,7 +14849,7 @@ export class RewardAddresses { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new RewardAddresses([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(RewardAddress.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -15206,7 +15213,7 @@ export class ScriptHashes { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new ScriptHashes([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(ScriptHash.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -16800,7 +16807,7 @@ export class TransactionBodies { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new TransactionBodies([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(TransactionBody.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -17995,7 +18002,7 @@ export class TransactionMetadatumLabels { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new TransactionMetadatumLabels([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(BigNum.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -18337,7 +18344,7 @@ export class TransactionOutputs { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new TransactionOutputs([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(TransactionOutput.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -18529,7 +18536,7 @@ export class TransactionUnspentOutputs { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new TransactionUnspentOutputs([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(TransactionUnspentOutput.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -18905,7 +18912,7 @@ export class TransactionWitnessSets { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new TransactionWitnessSets([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(TransactionWitnessSet.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -20168,7 +20175,7 @@ export class Vkeys { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new Vkeys([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(Vkey.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } @@ -20948,7 +20955,7 @@ export class Voters { let [isDefinite, prng1] = prand.uniformIntDistribution(0, 1, prng); let [len, prng_mut] = prand.uniformIntDistribution(0, 3, prng1); let ret = new Voters([], isDefinite > 0); - for (let _i = 0; _i < len; _i++) { + for (let i = 0; i < len; i++) { ret.add(Voter.arbitrary(prng_mut)); prand.unsafeSkipN(prng_mut, 1); } From ac3fa20eaa41b9522e8bf12e9435b6facac03271 Mon Sep 17 00:00:00 2001 From: rmgaray Date: Fri, 17 Jan 2025 13:15:22 -0300 Subject: [PATCH 6/6] support arbitrary in structured types & support more primitive types --- .../codegen/generators/structured/index.ts | 74 +- conway-cddl/codegen/main.ts | 1 + src/generated.ts | 1807 ++++++++++++++++- 3 files changed, 1792 insertions(+), 90 deletions(-) diff --git a/conway-cddl/codegen/generators/structured/index.ts b/conway-cddl/codegen/generators/structured/index.ts index 35c8085..b512c1b 100644 --- a/conway-cddl/codegen/generators/structured/index.ts +++ b/conway-cddl/codegen/generators/structured/index.ts @@ -31,7 +31,32 @@ export class GenStructuredBase< } private fieldType(field: Field) { - return `${this.typeUtils.jsType(field.type)} ${field.optional || field.nullable ? "| undefined" : ""}`; + return `${this.fieldBaseType(field)}${field.optional || field.nullable ? " | undefined" : ""}`; + } + + // this ignores undefined + private fieldBaseType(field: Field) { + return `${this.typeUtils.jsType(field.type)}`; + } + + // necessary because primitive fields do not have an arbitrary method + private fieldArbitrary(field: Field, prng: string): string { + let primitives: Set = new Set(["Uint8Array", "number", "boolean"]); + const fieldType: string = this.fieldBaseType(field); + if (primitives.has(fieldType) ) { + switch (fieldType) { + case "Uint8Array": + return `new Uint8Array(repeatRand(3, ${prng}, prand.uniformIntDistribution(0, 255))[0])`; + case "number": + return `prand.uniformIntDistribution(0, Number.MAX_SAFE_INTEGER, ${prng})[0]`; + case "boolean": + return `prand.unsafeUniformIntDistribution(0, 1, ${prng}) > 0`; + default: + throw new Error(`Unexpected primitive type ${fieldType}`); + } + } else { + return `${field.type}.arbitrary(${prng})`; + } } getFields(): Field[] { @@ -54,21 +79,21 @@ export class GenStructuredBase< .map((x) => `${x.name}: ${this.fieldType(x)}`) .join(", ")}) { ${this.getFields() - .map((x) => `this._${x.name} = ${x.name};`) - .join("\n")} + .map((x) => `this._${x.name} = ${x.name};`) + .join("\n")} } ${this.renameMethod( - "new", - (new_) => ` + "new", + (new_) => ` static ${new_}(${this.getFields() - .map((x) => `${x.name}: ${this.fieldType(x)}`) - .join(", ")}) { + .map((x) => `${x.name}: ${this.fieldType(x)}`) + .join(", ")}) { return new ${this.name}(${this.getFields() - .map((x) => x.name) - .join(",")}); + .map((x) => x.name) + .join(",")}); } ` - )} + )} `; } @@ -96,6 +121,35 @@ export class GenStructuredBase< .join("\n"); } + generateArbitrary(prng: string): string { + const generateField = (f: Field) => { + if (f.optional) { + return ` + let ${f.name}: ${this.fieldType(f)}; + const ${f.name}_defined = prand.unsafeUniformIntDistribution(0, 1, ${prng}); + if (${f.name}_defined) { + ${f.name} = ${this.fieldArbitrary(f, prng)}; + prand.unsafeSkipN(${prng}, 1); + } else { + ${f.name} = undefined; + } + ` + } else { + return ` + let ${f.name}: ${this.fieldType(f)}; + ${f.name} = ${this.fieldArbitrary(f, prng)}; + prand.unsafeSkipN(${prng}, 1); + ` + } + + } + return ` + ${this.getFields().map(generateField).join('\n')} + + return new ${this.name}(${this.getFields().map((f) => f.name)}); + ` + } + generateExtraMethods(): string { return this.generateAccessors(); } diff --git a/conway-cddl/codegen/main.ts b/conway-cddl/codegen/main.ts index 96cfee4..48f4ecf 100644 --- a/conway-cddl/codegen/main.ts +++ b/conway-cddl/codegen/main.ts @@ -87,6 +87,7 @@ async function main() { } import { RandomGenerator } from 'pure-rand'; import prand from 'pure-rand'; + import { repeatRand } from './lib/prand_utils'; function $$UN(id: string, ...args: any): any { throw ("Undefined function: " + id); diff --git a/src/generated.ts b/src/generated.ts index f6ceb0b..ed362e3 100644 --- a/src/generated.ts +++ b/src/generated.ts @@ -16,6 +16,7 @@ if (typeof globalThis.crypto === "undefined") { } import { RandomGenerator } from "pure-rand"; import prand from "pure-rand"; +import { repeatRand } from "./lib/prand_utils"; function $$UN(id: string, ...args: any): any { throw "Undefined function: " + id; @@ -87,7 +88,15 @@ export class Anchor { } static arbitrary(prng: RandomGenerator): Anchor { - throw new Error("Not Implemented"); + let url: URL; + url = URL.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let anchor_data_hash: AnchorDataHash; + anchor_data_hash = AnchorDataHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new Anchor(url, anchor_data_hash); } // no-op @@ -1091,7 +1100,74 @@ export class AuxiliaryDataPostAlonzo { } static arbitrary(prng: RandomGenerator): AuxiliaryDataPostAlonzo { - throw new Error("Not Implemented"); + let metadata: GeneralTransactionMetadata | undefined; + const metadata_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (metadata_defined) { + metadata = GeneralTransactionMetadata.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + metadata = undefined; + } + + let native_scripts: NativeScripts | undefined; + const native_scripts_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (native_scripts_defined) { + native_scripts = NativeScripts.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + native_scripts = undefined; + } + + let plutus_scripts_v1: PlutusScripts | undefined; + const plutus_scripts_v1_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (plutus_scripts_v1_defined) { + plutus_scripts_v1 = PlutusScripts.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + plutus_scripts_v1 = undefined; + } + + let plutus_scripts_v2: PlutusScripts | undefined; + const plutus_scripts_v2_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (plutus_scripts_v2_defined) { + plutus_scripts_v2 = PlutusScripts.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + plutus_scripts_v2 = undefined; + } + + let plutus_scripts_v3: PlutusScripts | undefined; + const plutus_scripts_v3_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (plutus_scripts_v3_defined) { + plutus_scripts_v3 = PlutusScripts.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + plutus_scripts_v3 = undefined; + } + + return new AuxiliaryDataPostAlonzo( + metadata, + native_scripts, + plutus_scripts_v1, + plutus_scripts_v2, + plutus_scripts_v3, + ); } // no-op @@ -1315,7 +1391,15 @@ export class AuxiliaryDataShelleyMa { } static arbitrary(prng: RandomGenerator): AuxiliaryDataShelleyMa { - throw new Error("Not Implemented"); + let transaction_metadata: GeneralTransactionMetadata; + transaction_metadata = GeneralTransactionMetadata.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let auxiliary_scripts: NativeScripts; + auxiliary_scripts = NativeScripts.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new AuxiliaryDataShelleyMa(transaction_metadata, auxiliary_scripts); } // no-op @@ -1865,7 +1949,33 @@ export class Block { } static arbitrary(prng: RandomGenerator): Block { - throw new Error("Not Implemented"); + let header: Header; + header = Header.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let transaction_bodies: TransactionBodies; + transaction_bodies = TransactionBodies.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let transaction_witness_sets: TransactionWitnessSets; + transaction_witness_sets = TransactionWitnessSets.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let auxiliary_data_set: AuxiliaryDataSet; + auxiliary_data_set = AuxiliaryDataSet.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let inner_invalid_transactions: InvalidTransactions; + inner_invalid_transactions = InvalidTransactions.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new Block( + header, + transaction_bodies, + transaction_witness_sets, + auxiliary_data_set, + inner_invalid_transactions, + ); } // no-op @@ -2092,7 +2202,27 @@ export class BootstrapWitness { } static arbitrary(prng: RandomGenerator): BootstrapWitness { - throw new Error("Not Implemented"); + let vkey: Vkey; + vkey = Vkey.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let signature: Ed25519Signature; + signature = Ed25519Signature.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let chain_code: Uint8Array; + chain_code = new Uint8Array( + repeatRand(3, prng, prand.uniformIntDistribution(0, 255))[0], + ); + prand.unsafeSkipN(prng, 1); + + let attributes: Uint8Array; + attributes = new Uint8Array( + repeatRand(3, prng, prand.uniformIntDistribution(0, 255))[0], + ); + prand.unsafeSkipN(prng, 1); + + return new BootstrapWitness(vkey, signature, chain_code, attributes); } // no-op @@ -3241,7 +3371,19 @@ export class ChangeConfig { } static arbitrary(prng: RandomGenerator): ChangeConfig { - throw new Error("Not Implemented"); + let address: Address; + address = Address.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let plutus_data: OutputDatum | undefined; + plutus_data = OutputDatum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let script_ref: ScriptRef | undefined; + script_ref = ScriptRef.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new ChangeConfig(address, plutus_data, script_ref); } // no-op @@ -3377,7 +3519,15 @@ export class CommitteeColdResign { } static arbitrary(prng: RandomGenerator): CommitteeColdResign { - throw new Error("Not Implemented"); + let committee_cold_credential: Credential; + committee_cold_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let anchor: Anchor | undefined; + anchor = Anchor.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new CommitteeColdResign(committee_cold_credential, anchor); } // no-op @@ -3583,7 +3733,18 @@ export class CommitteeHotAuth { } static arbitrary(prng: RandomGenerator): CommitteeHotAuth { - throw new Error("Not Implemented"); + let committee_cold_credential: Credential; + committee_cold_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let committee_hot_credential: Credential; + committee_hot_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new CommitteeHotAuth( + committee_cold_credential, + committee_hot_credential, + ); } // no-op @@ -3683,7 +3844,15 @@ export class Constitution { } static arbitrary(prng: RandomGenerator): Constitution { - throw new Error("Not Implemented"); + let anchor: Anchor; + anchor = Anchor.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let script_hash: ScriptHash | undefined; + script_hash = ScriptHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new Constitution(anchor, script_hash); } // no-op @@ -3792,7 +3961,15 @@ export class ConstrPlutusData { } static arbitrary(prng: RandomGenerator): ConstrPlutusData { - throw new Error("Not Implemented"); + let alternative: BigNum; + alternative = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let data: PlutusList; + data = PlutusList.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new ConstrPlutusData(alternative, data); } // no-op @@ -4522,7 +4699,15 @@ export class DRepDeregistration { } static arbitrary(prng: RandomGenerator): DRepDeregistration { - throw new Error("Not Implemented"); + let drep_credential: Credential; + drep_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let coin: BigNum; + coin = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new DRepDeregistration(drep_credential, coin); } // no-op @@ -4625,7 +4810,19 @@ export class DRepRegistration { } static arbitrary(prng: RandomGenerator): DRepRegistration { - throw new Error("Not Implemented"); + let voting_credential: Credential; + voting_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let coin: BigNum; + coin = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let anchor: Anchor | undefined; + anchor = Anchor.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new DRepRegistration(voting_credential, coin, anchor); } // no-op @@ -4722,7 +4919,15 @@ export class DRepUpdate { } static arbitrary(prng: RandomGenerator): DRepUpdate { - throw new Error("Not Implemented"); + let drep_credential: Credential; + drep_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let anchor: Anchor | undefined; + anchor = Anchor.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new DRepUpdate(drep_credential, anchor); } // no-op @@ -5032,7 +5237,58 @@ export class DRepVotingThresholds { } static arbitrary(prng: RandomGenerator): DRepVotingThresholds { - throw new Error("Not Implemented"); + let motion_no_confidence: UnitInterval; + motion_no_confidence = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let committee_normal: UnitInterval; + committee_normal = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let committee_no_confidence: UnitInterval; + committee_no_confidence = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let update_constitution: UnitInterval; + update_constitution = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let hard_fork_initiation: UnitInterval; + hard_fork_initiation = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let pp_network_group: UnitInterval; + pp_network_group = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let pp_economic_group: UnitInterval; + pp_economic_group = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let pp_technical_group: UnitInterval; + pp_technical_group = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let pp_governance_group: UnitInterval; + pp_governance_group = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let treasury_withdrawal: UnitInterval; + treasury_withdrawal = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new DRepVotingThresholds( + motion_no_confidence, + committee_normal, + committee_no_confidence, + update_constitution, + hard_fork_initiation, + pp_network_group, + pp_economic_group, + pp_technical_group, + pp_governance_group, + treasury_withdrawal, + ); } // no-op @@ -5185,7 +5441,11 @@ export class DataCost { } static arbitrary(prng: RandomGenerator): DataCost { - throw new Error("Not Implemented"); + let coins_per_byte: BigNum; + coins_per_byte = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new DataCost(coins_per_byte); } // no-op @@ -5875,7 +6135,15 @@ export class ExUnitPrices { } static arbitrary(prng: RandomGenerator): ExUnitPrices { - throw new Error("Not Implemented"); + let mem_price: UnitInterval; + mem_price = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let step_price: UnitInterval; + step_price = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new ExUnitPrices(mem_price, step_price); } // no-op @@ -5971,7 +6239,15 @@ export class ExUnits { } static arbitrary(prng: RandomGenerator): ExUnits { - throw new Error("Not Implemented"); + let mem: BigNum; + mem = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let steps: BigNum; + steps = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new ExUnits(mem, steps); } // no-op @@ -6714,7 +6990,15 @@ export class GovernanceActionId { } static arbitrary(prng: RandomGenerator): GovernanceActionId { - throw new Error("Not Implemented"); + let transaction_id: TransactionHash; + transaction_id = TransactionHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let index: number; + index = prand.uniformIntDistribution(0, Number.MAX_SAFE_INTEGER, prng)[0]; + prand.unsafeSkipN(prng, 1); + + return new GovernanceActionId(transaction_id, index); } // no-op @@ -7014,7 +7298,15 @@ export class HardForkInitiationAction { } static arbitrary(prng: RandomGenerator): HardForkInitiationAction { - throw new Error("Not Implemented"); + let gov_action_id: GovernanceActionId | undefined; + gov_action_id = GovernanceActionId.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let protocol_version: ProtocolVersion; + protocol_version = ProtocolVersion.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new HardForkInitiationAction(gov_action_id, protocol_version); } // no-op @@ -7114,7 +7406,15 @@ export class Header { } static arbitrary(prng: RandomGenerator): Header { - throw new Error("Not Implemented"); + let header_body: HeaderBody; + header_body = HeaderBody.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let body_signature: KESSignature; + body_signature = KESSignature.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new Header(header_body, body_signature); } // no-op @@ -7380,7 +7680,66 @@ export class HeaderBody { } static arbitrary(prng: RandomGenerator): HeaderBody { - throw new Error("Not Implemented"); + let block_number: number; + block_number = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + + let slot: BigNum; + slot = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let prev_hash: BlockHash | undefined; + prev_hash = BlockHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let issuer_vkey: Vkey; + issuer_vkey = Vkey.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let vrf_vkey: VRFVKey; + vrf_vkey = VRFVKey.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let vrf_result: VRFCert; + vrf_result = VRFCert.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let block_body_size: number; + block_body_size = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + + let block_body_hash: BlockHash; + block_body_hash = BlockHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let operational_cert: OperationalCert; + operational_cert = OperationalCert.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let protocol_version: ProtocolVersion; + protocol_version = ProtocolVersion.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new HeaderBody( + block_number, + slot, + prev_hash, + issuer_vkey, + vrf_vkey, + vrf_result, + block_body_size, + block_body_hash, + operational_cert, + protocol_version, + ); } // no-op @@ -7460,7 +7819,7 @@ export class InfoAction { serialize(writer: CBORWriter): void {} static arbitrary(prng: RandomGenerator): InfoAction { - throw new Error("Not Implemented"); + return new InfoAction(); } // no-op @@ -8900,7 +9259,11 @@ export class MultiHostName { } static arbitrary(prng: RandomGenerator): MultiHostName { - throw new Error("Not Implemented"); + let dns_name: DNSRecordSRV; + dns_name = DNSRecordSRV.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new MultiHostName(dns_name); } // no-op @@ -9267,7 +9630,23 @@ export class NativeScriptRefInput { } static arbitrary(prng: RandomGenerator): NativeScriptRefInput { - throw new Error("Not Implemented"); + let script_hash: ScriptHash; + script_hash = ScriptHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let input: TransactionInput; + input = TransactionInput.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let script_size: number; + script_size = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + + return new NativeScriptRefInput(script_hash, input, script_size); } // no-op @@ -9709,7 +10088,15 @@ export class NewConstitutionAction { } static arbitrary(prng: RandomGenerator): NewConstitutionAction { - throw new Error("Not Implemented"); + let gov_action_id: GovernanceActionId | undefined; + gov_action_id = GovernanceActionId.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let constitution: Constitution; + constitution = Constitution.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new NewConstitutionAction(gov_action_id, constitution); } // no-op @@ -9787,7 +10174,11 @@ export class NoConfidenceAction { } static arbitrary(prng: RandomGenerator): NoConfidenceAction { - throw new Error("Not Implemented"); + let gov_action_id: GovernanceActionId | undefined; + gov_action_id = GovernanceActionId.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new NoConfidenceAction(gov_action_id); } // no-op @@ -9878,7 +10269,13 @@ export class Nonce { } static arbitrary(prng: RandomGenerator): Nonce { - throw new Error("Not Implemented"); + let hash: Uint8Array | undefined; + hash = new Uint8Array( + repeatRand(3, prng, prand.uniformIntDistribution(0, 255))[0], + ); + prand.unsafeSkipN(prng, 1); + + return new Nonce(hash); } // no-op @@ -10016,7 +10413,31 @@ export class OperationalCert { } static arbitrary(prng: RandomGenerator): OperationalCert { - throw new Error("Not Implemented"); + let hot_vkey: KESVKey; + hot_vkey = KESVKey.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let sequence_number: number; + sequence_number = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + + let kes_period: number; + kes_period = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + + let sigma: Ed25519Signature; + sigma = Ed25519Signature.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new OperationalCert(hot_vkey, sequence_number, kes_period, sigma); } // no-op @@ -10281,7 +10702,23 @@ export class ParameterChangeAction { } static arbitrary(prng: RandomGenerator): ParameterChangeAction { - throw new Error("Not Implemented"); + let gov_action_id: GovernanceActionId | undefined; + gov_action_id = GovernanceActionId.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let protocol_param_updates: ProtocolParamUpdate; + protocol_param_updates = ProtocolParamUpdate.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let policy_hash: ScriptHash | undefined; + policy_hash = ScriptHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new ParameterChangeAction( + gov_action_id, + protocol_param_updates, + policy_hash, + ); } // no-op @@ -11243,7 +11680,15 @@ export class PoolMetadata { } static arbitrary(prng: RandomGenerator): PoolMetadata { - throw new Error("Not Implemented"); + let url: URL; + url = URL.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let pool_metadata_hash: PoolMetadataHash; + pool_metadata_hash = PoolMetadataHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new PoolMetadata(url, pool_metadata_hash); } // no-op @@ -11540,7 +11985,53 @@ export class PoolParams { } static arbitrary(prng: RandomGenerator): PoolParams { - throw new Error("Not Implemented"); + let operator: Ed25519KeyHash; + operator = Ed25519KeyHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let vrf_keyhash: VRFKeyHash; + vrf_keyhash = VRFKeyHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let pledge: BigNum; + pledge = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let cost: BigNum; + cost = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let margin: UnitInterval; + margin = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let reward_account: RewardAddress; + reward_account = RewardAddress.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let pool_owners: Ed25519KeyHashes; + pool_owners = Ed25519KeyHashes.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let relays: Relays; + relays = Relays.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let pool_metadata: PoolMetadata | undefined; + pool_metadata = PoolMetadata.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new PoolParams( + operator, + vrf_keyhash, + pledge, + cost, + margin, + reward_account, + pool_owners, + relays, + pool_metadata, + ); } // no-op @@ -11605,7 +12096,11 @@ export class PoolRegistration { } static arbitrary(prng: RandomGenerator): PoolRegistration { - throw new Error("Not Implemented"); + let pool_params: PoolParams; + pool_params = PoolParams.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new PoolRegistration(pool_params); } // no-op @@ -11687,7 +12182,15 @@ export class PoolRetirement { } static arbitrary(prng: RandomGenerator): PoolRetirement { - throw new Error("Not Implemented"); + let pool_keyhash: Ed25519KeyHash; + pool_keyhash = Ed25519KeyHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let epoch: number; + epoch = prand.uniformIntDistribution(0, Number.MAX_SAFE_INTEGER, prng)[0]; + prand.unsafeSkipN(prng, 1); + + return new PoolRetirement(pool_keyhash, epoch); } // no-op @@ -11878,15 +12381,41 @@ export class PoolVotingThresholds { } static arbitrary(prng: RandomGenerator): PoolVotingThresholds { - throw new Error("Not Implemented"); - } + let motion_no_confidence: UnitInterval; + motion_no_confidence = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); - // no-op - free(): void {} + let committee_normal: UnitInterval; + committee_normal = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); - static from_bytes( - data: Uint8Array, - path: string[] = ["PoolVotingThresholds"], + let committee_no_confidence: UnitInterval; + committee_no_confidence = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let hard_fork_initiation: UnitInterval; + hard_fork_initiation = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let security_relevant_threshold: UnitInterval; + security_relevant_threshold = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new PoolVotingThresholds( + motion_no_confidence, + committee_normal, + committee_no_confidence, + hard_fork_initiation, + security_relevant_threshold, + ); + } + + // no-op + free(): void {} + + static from_bytes( + data: Uint8Array, + path: string[] = ["PoolVotingThresholds"], ): PoolVotingThresholds { let reader = new CBORReader(data); return PoolVotingThresholds.deserialize(reader, path); @@ -12058,7 +12587,38 @@ export class PostAlonzoTransactionOutput { } static arbitrary(prng: RandomGenerator): PostAlonzoTransactionOutput { - throw new Error("Not Implemented"); + let address: Address; + address = Address.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let amount: Value; + amount = Value.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let datum_option: DataOption | undefined; + const datum_option_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (datum_option_defined) { + datum_option = DataOption.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + datum_option = undefined; + } + + let script_ref: ScriptRef | undefined; + const script_ref_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (script_ref_defined) { + script_ref = ScriptRef.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + script_ref = undefined; + } + + return new PostAlonzoTransactionOutput( + address, + amount, + datum_option, + script_ref, + ); } // no-op @@ -12188,7 +12748,24 @@ export class PreBabbageTransactionOutput { } static arbitrary(prng: RandomGenerator): PreBabbageTransactionOutput { - throw new Error("Not Implemented"); + let address: Address; + address = Address.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let amount: Value; + amount = Value.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let datum_hash: DataHash | undefined; + const datum_hash_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (datum_hash_defined) { + datum_hash = DataHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + datum_hash = undefined; + } + + return new PreBabbageTransactionOutput(address, amount, datum_hash); } // no-op @@ -13281,7 +13858,427 @@ export class ProtocolParamUpdate { } static arbitrary(prng: RandomGenerator): ProtocolParamUpdate { - throw new Error("Not Implemented"); + let minfee_a: BigNum | undefined; + const minfee_a_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (minfee_a_defined) { + minfee_a = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + minfee_a = undefined; + } + + let minfee_b: BigNum | undefined; + const minfee_b_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (minfee_b_defined) { + minfee_b = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + minfee_b = undefined; + } + + let max_block_body_size: number | undefined; + const max_block_body_size_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (max_block_body_size_defined) { + max_block_body_size = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + } else { + max_block_body_size = undefined; + } + + let max_tx_size: number | undefined; + const max_tx_size_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (max_tx_size_defined) { + max_tx_size = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + } else { + max_tx_size = undefined; + } + + let max_block_header_size: number | undefined; + const max_block_header_size_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (max_block_header_size_defined) { + max_block_header_size = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + } else { + max_block_header_size = undefined; + } + + let key_deposit: BigNum | undefined; + const key_deposit_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (key_deposit_defined) { + key_deposit = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + key_deposit = undefined; + } + + let pool_deposit: BigNum | undefined; + const pool_deposit_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (pool_deposit_defined) { + pool_deposit = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + pool_deposit = undefined; + } + + let max_epoch: number | undefined; + const max_epoch_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (max_epoch_defined) { + max_epoch = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + } else { + max_epoch = undefined; + } + + let n_opt: number | undefined; + const n_opt_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (n_opt_defined) { + n_opt = prand.uniformIntDistribution(0, Number.MAX_SAFE_INTEGER, prng)[0]; + prand.unsafeSkipN(prng, 1); + } else { + n_opt = undefined; + } + + let pool_pledge_influence: UnitInterval | undefined; + const pool_pledge_influence_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (pool_pledge_influence_defined) { + pool_pledge_influence = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + pool_pledge_influence = undefined; + } + + let expansion_rate: UnitInterval | undefined; + const expansion_rate_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (expansion_rate_defined) { + expansion_rate = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + expansion_rate = undefined; + } + + let treasury_growth_rate: UnitInterval | undefined; + const treasury_growth_rate_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (treasury_growth_rate_defined) { + treasury_growth_rate = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + treasury_growth_rate = undefined; + } + + let min_pool_cost: BigNum | undefined; + const min_pool_cost_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (min_pool_cost_defined) { + min_pool_cost = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + min_pool_cost = undefined; + } + + let ada_per_utxo_byte: BigNum | undefined; + const ada_per_utxo_byte_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (ada_per_utxo_byte_defined) { + ada_per_utxo_byte = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + ada_per_utxo_byte = undefined; + } + + let cost_models: Costmdls | undefined; + const cost_models_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (cost_models_defined) { + cost_models = Costmdls.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + cost_models = undefined; + } + + let execution_costs: ExUnitPrices | undefined; + const execution_costs_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (execution_costs_defined) { + execution_costs = ExUnitPrices.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + execution_costs = undefined; + } + + let max_tx_ex_units: ExUnits | undefined; + const max_tx_ex_units_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (max_tx_ex_units_defined) { + max_tx_ex_units = ExUnits.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + max_tx_ex_units = undefined; + } + + let max_block_ex_units: ExUnits | undefined; + const max_block_ex_units_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (max_block_ex_units_defined) { + max_block_ex_units = ExUnits.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + max_block_ex_units = undefined; + } + + let max_value_size: number | undefined; + const max_value_size_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (max_value_size_defined) { + max_value_size = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + } else { + max_value_size = undefined; + } + + let collateral_percentage: number | undefined; + const collateral_percentage_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (collateral_percentage_defined) { + collateral_percentage = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + } else { + collateral_percentage = undefined; + } + + let max_collateral_inputs: number | undefined; + const max_collateral_inputs_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (max_collateral_inputs_defined) { + max_collateral_inputs = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + } else { + max_collateral_inputs = undefined; + } + + let pool_voting_thresholds: PoolVotingThresholds | undefined; + const pool_voting_thresholds_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (pool_voting_thresholds_defined) { + pool_voting_thresholds = PoolVotingThresholds.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + pool_voting_thresholds = undefined; + } + + let drep_voting_thresholds: DRepVotingThresholds | undefined; + const drep_voting_thresholds_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (drep_voting_thresholds_defined) { + drep_voting_thresholds = DRepVotingThresholds.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + drep_voting_thresholds = undefined; + } + + let min_committee_size: number | undefined; + const min_committee_size_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (min_committee_size_defined) { + min_committee_size = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + } else { + min_committee_size = undefined; + } + + let committee_term_limit: number | undefined; + const committee_term_limit_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (committee_term_limit_defined) { + committee_term_limit = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + } else { + committee_term_limit = undefined; + } + + let governance_action_validity_period: number | undefined; + const governance_action_validity_period_defined = + prand.unsafeUniformIntDistribution(0, 1, prng); + if (governance_action_validity_period_defined) { + governance_action_validity_period = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + } else { + governance_action_validity_period = undefined; + } + + let governance_action_deposit: BigNum | undefined; + const governance_action_deposit_defined = + prand.unsafeUniformIntDistribution(0, 1, prng); + if (governance_action_deposit_defined) { + governance_action_deposit = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + governance_action_deposit = undefined; + } + + let drep_deposit: BigNum | undefined; + const drep_deposit_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (drep_deposit_defined) { + drep_deposit = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + drep_deposit = undefined; + } + + let drep_inactivity_period: number | undefined; + const drep_inactivity_period_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (drep_inactivity_period_defined) { + drep_inactivity_period = prand.uniformIntDistribution( + 0, + Number.MAX_SAFE_INTEGER, + prng, + )[0]; + prand.unsafeSkipN(prng, 1); + } else { + drep_inactivity_period = undefined; + } + + let ref_script_coins_per_byte: UnitInterval | undefined; + const ref_script_coins_per_byte_defined = + prand.unsafeUniformIntDistribution(0, 1, prng); + if (ref_script_coins_per_byte_defined) { + ref_script_coins_per_byte = UnitInterval.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + ref_script_coins_per_byte = undefined; + } + + return new ProtocolParamUpdate( + minfee_a, + minfee_b, + max_block_body_size, + max_tx_size, + max_block_header_size, + key_deposit, + pool_deposit, + max_epoch, + n_opt, + pool_pledge_influence, + expansion_rate, + treasury_growth_rate, + min_pool_cost, + ada_per_utxo_byte, + cost_models, + execution_costs, + max_tx_ex_units, + max_block_ex_units, + max_value_size, + collateral_percentage, + max_collateral_inputs, + pool_voting_thresholds, + drep_voting_thresholds, + min_committee_size, + committee_term_limit, + governance_action_validity_period, + governance_action_deposit, + drep_deposit, + drep_inactivity_period, + ref_script_coins_per_byte, + ); } // no-op @@ -13412,7 +14409,15 @@ export class ProtocolVersion { } static arbitrary(prng: RandomGenerator): ProtocolVersion { - throw new Error("Not Implemented"); + let major: number; + major = prand.uniformIntDistribution(0, Number.MAX_SAFE_INTEGER, prng)[0]; + prand.unsafeSkipN(prng, 1); + + let minor: number; + minor = prand.uniformIntDistribution(0, Number.MAX_SAFE_INTEGER, prng)[0]; + prand.unsafeSkipN(prng, 1); + + return new ProtocolVersion(major, minor); } // no-op @@ -14068,7 +15073,23 @@ export class RedeemersArrayItem { } static arbitrary(prng: RandomGenerator): RedeemersArrayItem { - throw new Error("Not Implemented"); + let tag: RedeemerTag; + tag = RedeemerTag.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let index: BigNum; + index = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let data: PlutusData; + data = PlutusData.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let ex_units: ExUnits; + ex_units = ExUnits.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new RedeemersArrayItem(tag, index, data, ex_units); } // no-op @@ -14164,7 +15185,15 @@ export class RedeemersKey { } static arbitrary(prng: RandomGenerator): RedeemersKey { - throw new Error("Not Implemented"); + let tag: RedeemerTag; + tag = RedeemerTag.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let index: BigNum; + index = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new RedeemersKey(tag, index); } // no-op @@ -14455,7 +15484,15 @@ export class RedeemersValue { } static arbitrary(prng: RandomGenerator): RedeemersValue { - throw new Error("Not Implemented"); + let data: PlutusData; + data = PlutusData.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let ex_units: ExUnits; + ex_units = ExUnits.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new RedeemersValue(data, ex_units); } // no-op @@ -14537,7 +15574,15 @@ export class RegCert { } static arbitrary(prng: RandomGenerator): RegCert { - throw new Error("Not Implemented"); + let stake_credential: Credential; + stake_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let coin: BigNum; + coin = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new RegCert(stake_credential, coin); } // no-op @@ -14922,7 +15967,11 @@ export class ScriptAll { } static arbitrary(prng: RandomGenerator): ScriptAll { - throw new Error("Not Implemented"); + let native_scripts: NativeScripts; + native_scripts = NativeScripts.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new ScriptAll(native_scripts); } // no-op @@ -14988,7 +16037,11 @@ export class ScriptAny { } static arbitrary(prng: RandomGenerator): ScriptAny { - throw new Error("Not Implemented"); + let native_scripts: NativeScripts; + native_scripts = NativeScripts.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new ScriptAny(native_scripts); } // no-op @@ -15299,7 +16352,15 @@ export class ScriptNOfK { } static arbitrary(prng: RandomGenerator): ScriptNOfK { - throw new Error("Not Implemented"); + let n: number; + n = prand.uniformIntDistribution(0, Number.MAX_SAFE_INTEGER, prng)[0]; + prand.unsafeSkipN(prng, 1); + + let native_scripts: NativeScripts; + native_scripts = NativeScripts.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new ScriptNOfK(n, native_scripts); } // no-op @@ -15428,7 +16489,11 @@ export class ScriptPubname { } static arbitrary(prng: RandomGenerator): ScriptPubname { - throw new Error("Not Implemented"); + let addr_keyhash: Ed25519KeyHash; + addr_keyhash = Ed25519KeyHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new ScriptPubname(addr_keyhash); } // no-op @@ -15757,7 +16822,19 @@ export class SingleHostAddr { } static arbitrary(prng: RandomGenerator): SingleHostAddr { - throw new Error("Not Implemented"); + let port: number | undefined; + port = prand.uniformIntDistribution(0, Number.MAX_SAFE_INTEGER, prng)[0]; + prand.unsafeSkipN(prng, 1); + + let ipv4: Ipv4 | undefined; + ipv4 = Ipv4.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let ipv6: Ipv6 | undefined; + ipv6 = Ipv6.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new SingleHostAddr(port, ipv4, ipv6); } // no-op @@ -15842,7 +16919,15 @@ export class SingleHostName { } static arbitrary(prng: RandomGenerator): SingleHostName { - throw new Error("Not Implemented"); + let port: number | undefined; + port = prand.uniformIntDistribution(0, Number.MAX_SAFE_INTEGER, prng)[0]; + prand.unsafeSkipN(prng, 1); + + let dns_name: DNSRecordAorAAAA; + dns_name = DNSRecordAorAAAA.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new SingleHostName(port, dns_name); } // no-op @@ -15951,7 +17036,19 @@ export class StakeAndVoteDelegation { } static arbitrary(prng: RandomGenerator): StakeAndVoteDelegation { - throw new Error("Not Implemented"); + let stake_credential: Credential; + stake_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let pool_keyhash: Ed25519KeyHash; + pool_keyhash = Ed25519KeyHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let drep: DRep; + drep = DRep.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new StakeAndVoteDelegation(stake_credential, pool_keyhash, drep); } // no-op @@ -16036,7 +17133,15 @@ export class StakeDelegation { } static arbitrary(prng: RandomGenerator): StakeDelegation { - throw new Error("Not Implemented"); + let stake_credential: Credential; + stake_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let pool_keyhash: Ed25519KeyHash; + pool_keyhash = Ed25519KeyHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new StakeDelegation(stake_credential, pool_keyhash); } // no-op @@ -16105,7 +17210,11 @@ export class StakeDeregistration { } static arbitrary(prng: RandomGenerator): StakeDeregistration { - throw new Error("Not Implemented"); + let stake_credential: Credential; + stake_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new StakeDeregistration(stake_credential); } // no-op @@ -16174,7 +17283,11 @@ export class StakeRegistration { } static arbitrary(prng: RandomGenerator): StakeRegistration { - throw new Error("Not Implemented"); + let stake_credential: Credential; + stake_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new StakeRegistration(stake_credential); } // no-op @@ -16291,7 +17404,23 @@ export class StakeRegistrationAndDelegation { } static arbitrary(prng: RandomGenerator): StakeRegistrationAndDelegation { - throw new Error("Not Implemented"); + let stake_credential: Credential; + stake_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let pool_keyhash: Ed25519KeyHash; + pool_keyhash = Ed25519KeyHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let coin: BigNum; + coin = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new StakeRegistrationAndDelegation( + stake_credential, + pool_keyhash, + coin, + ); } // no-op @@ -16425,7 +17554,28 @@ export class StakeVoteRegistrationAndDelegation { } static arbitrary(prng: RandomGenerator): StakeVoteRegistrationAndDelegation { - throw new Error("Not Implemented"); + let stake_credential: Credential; + stake_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let pool_keyhash: Ed25519KeyHash; + pool_keyhash = Ed25519KeyHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let drep: DRep; + drep = DRep.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let coin: BigNum; + coin = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new StakeVoteRegistrationAndDelegation( + stake_credential, + pool_keyhash, + drep, + coin, + ); } // no-op @@ -16494,7 +17644,11 @@ export class TimelockExpiry { } static arbitrary(prng: RandomGenerator): TimelockExpiry { - throw new Error("Not Implemented"); + let slot: BigNum; + slot = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new TimelockExpiry(slot); } // no-op @@ -16568,7 +17722,11 @@ export class TimelockStart { } static arbitrary(prng: RandomGenerator): TimelockStart { - throw new Error("Not Implemented"); + let slot: BigNum; + slot = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new TimelockStart(slot); } // no-op @@ -16712,7 +17870,23 @@ export class Transaction { } static arbitrary(prng: RandomGenerator): Transaction { - throw new Error("Not Implemented"); + let body: TransactionBody; + body = TransactionBody.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let witness_set: TransactionWitnessSet; + witness_set = TransactionWitnessSet.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let is_valid: boolean; + is_valid = prand.unsafeUniformIntDistribution(0, 1, prng) > 0; + prand.unsafeSkipN(prng, 1); + + let auxiliary_data: AuxiliaryData | undefined; + auxiliary_data = AuxiliaryData.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new Transaction(body, witness_set, is_valid, auxiliary_data); } // no-op @@ -17384,7 +18558,233 @@ export class TransactionBody { } static arbitrary(prng: RandomGenerator): TransactionBody { - throw new Error("Not Implemented"); + let inputs: TransactionInputs; + inputs = TransactionInputs.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let outputs: TransactionOutputs; + outputs = TransactionOutputs.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let fee: BigNum; + fee = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let ttl: BigNum | undefined; + const ttl_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (ttl_defined) { + ttl = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + ttl = undefined; + } + + let certs: Certificates | undefined; + const certs_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (certs_defined) { + certs = Certificates.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + certs = undefined; + } + + let withdrawals: Withdrawals | undefined; + const withdrawals_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (withdrawals_defined) { + withdrawals = Withdrawals.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + withdrawals = undefined; + } + + let auxiliary_data_hash: AuxiliaryDataHash | undefined; + const auxiliary_data_hash_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (auxiliary_data_hash_defined) { + auxiliary_data_hash = AuxiliaryDataHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + auxiliary_data_hash = undefined; + } + + let validity_start_interval: BigNum | undefined; + const validity_start_interval_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (validity_start_interval_defined) { + validity_start_interval = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + validity_start_interval = undefined; + } + + let mint: Mint | undefined; + const mint_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (mint_defined) { + mint = Mint.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + mint = undefined; + } + + let script_data_hash: ScriptDataHash | undefined; + const script_data_hash_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (script_data_hash_defined) { + script_data_hash = ScriptDataHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + script_data_hash = undefined; + } + + let collateral: TransactionInputs | undefined; + const collateral_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (collateral_defined) { + collateral = TransactionInputs.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + collateral = undefined; + } + + let required_signers: Ed25519KeyHashes | undefined; + const required_signers_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (required_signers_defined) { + required_signers = Ed25519KeyHashes.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + required_signers = undefined; + } + + let network_id: NetworkId | undefined; + const network_id_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (network_id_defined) { + network_id = NetworkId.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + network_id = undefined; + } + + let collateral_return: TransactionOutput | undefined; + const collateral_return_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (collateral_return_defined) { + collateral_return = TransactionOutput.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + collateral_return = undefined; + } + + let total_collateral: BigNum | undefined; + const total_collateral_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (total_collateral_defined) { + total_collateral = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + total_collateral = undefined; + } + + let reference_inputs: TransactionInputs | undefined; + const reference_inputs_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (reference_inputs_defined) { + reference_inputs = TransactionInputs.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + reference_inputs = undefined; + } + + let voting_procedures: VotingProcedures | undefined; + const voting_procedures_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (voting_procedures_defined) { + voting_procedures = VotingProcedures.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + voting_procedures = undefined; + } + + let voting_proposals: VotingProposals | undefined; + const voting_proposals_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (voting_proposals_defined) { + voting_proposals = VotingProposals.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + voting_proposals = undefined; + } + + let current_treasury_value: BigNum | undefined; + const current_treasury_value_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (current_treasury_value_defined) { + current_treasury_value = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + current_treasury_value = undefined; + } + + let donation: BigNum | undefined; + const donation_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (donation_defined) { + donation = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + donation = undefined; + } + + return new TransactionBody( + inputs, + outputs, + fee, + ttl, + certs, + withdrawals, + auxiliary_data_hash, + validity_start_interval, + mint, + script_data_hash, + collateral, + required_signers, + network_id, + collateral_return, + total_collateral, + reference_inputs, + voting_procedures, + voting_proposals, + current_treasury_value, + donation, + ); } // no-op @@ -17614,7 +19014,15 @@ export class TransactionInput { } static arbitrary(prng: RandomGenerator): TransactionInput { - throw new Error("Not Implemented"); + let transaction_id: TransactionHash; + transaction_id = TransactionHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let index: number; + index = prand.uniformIntDistribution(0, Number.MAX_SAFE_INTEGER, prng)[0]; + prand.unsafeSkipN(prng, 1); + + return new TransactionInput(transaction_id, index); } // no-op @@ -18447,7 +19855,15 @@ export class TransactionUnspentOutput { } static arbitrary(prng: RandomGenerator): TransactionUnspentOutput { - throw new Error("Not Implemented"); + let input: TransactionInput; + input = TransactionInput.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let output: TransactionOutput; + output = TransactionOutput.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new TransactionUnspentOutput(input, output); } // no-op @@ -18802,7 +20218,108 @@ export class TransactionWitnessSet { } static arbitrary(prng: RandomGenerator): TransactionWitnessSet { - throw new Error("Not Implemented"); + let vkeys: Vkeywitnesses | undefined; + const vkeys_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (vkeys_defined) { + vkeys = Vkeywitnesses.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + vkeys = undefined; + } + + let native_scripts: NativeScripts | undefined; + const native_scripts_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (native_scripts_defined) { + native_scripts = NativeScripts.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + native_scripts = undefined; + } + + let bootstraps: BootstrapWitnesses | undefined; + const bootstraps_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (bootstraps_defined) { + bootstraps = BootstrapWitnesses.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + bootstraps = undefined; + } + + let plutus_scripts_v1: PlutusScripts | undefined; + const plutus_scripts_v1_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (plutus_scripts_v1_defined) { + plutus_scripts_v1 = PlutusScripts.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + plutus_scripts_v1 = undefined; + } + + let inner_plutus_data: PlutusSet | undefined; + const inner_plutus_data_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (inner_plutus_data_defined) { + inner_plutus_data = PlutusSet.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + inner_plutus_data = undefined; + } + + let plutus_scripts_v2: PlutusScripts | undefined; + const plutus_scripts_v2_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (plutus_scripts_v2_defined) { + plutus_scripts_v2 = PlutusScripts.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + plutus_scripts_v2 = undefined; + } + + let redeemers: Redeemers | undefined; + const redeemers_defined = prand.unsafeUniformIntDistribution(0, 1, prng); + if (redeemers_defined) { + redeemers = Redeemers.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + redeemers = undefined; + } + + let plutus_scripts_v3: PlutusScripts | undefined; + const plutus_scripts_v3_defined = prand.unsafeUniformIntDistribution( + 0, + 1, + prng, + ); + if (plutus_scripts_v3_defined) { + plutus_scripts_v3 = PlutusScripts.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + } else { + plutus_scripts_v3 = undefined; + } + + return new TransactionWitnessSet( + vkeys, + native_scripts, + bootstraps, + plutus_scripts_v1, + inner_plutus_data, + plutus_scripts_v2, + redeemers, + plutus_scripts_v3, + ); } // no-op @@ -19120,7 +20637,15 @@ export class TreasuryWithdrawalsAction { } static arbitrary(prng: RandomGenerator): TreasuryWithdrawalsAction { - throw new Error("Not Implemented"); + let withdrawals: TreasuryWithdrawals; + withdrawals = TreasuryWithdrawals.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let policy_hash: ScriptHash | undefined; + policy_hash = ScriptHash.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new TreasuryWithdrawalsAction(withdrawals, policy_hash); } // no-op @@ -19297,7 +20822,15 @@ export class UnitInterval { } static arbitrary(prng: RandomGenerator): UnitInterval { - throw new Error("Not Implemented"); + let numerator: BigNum; + numerator = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let denominator: BigNum; + denominator = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new UnitInterval(numerator, denominator); } // no-op @@ -19379,7 +20912,15 @@ export class UnregCert { } static arbitrary(prng: RandomGenerator): UnregCert { - throw new Error("Not Implemented"); + let stake_credential: Credential; + stake_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let coin: BigNum; + coin = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new UnregCert(stake_credential, coin); } // no-op @@ -19489,7 +21030,16 @@ export class Update { } static arbitrary(prng: RandomGenerator): Update { - throw new Error("Not Implemented"); + let proposed_protocol_parameter_updates: ProposedProtocolParameterUpdates; + proposed_protocol_parameter_updates = + ProposedProtocolParameterUpdates.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let epoch: number; + epoch = prand.uniformIntDistribution(0, Number.MAX_SAFE_INTEGER, prng)[0]; + prand.unsafeSkipN(prng, 1); + + return new Update(proposed_protocol_parameter_updates, epoch); } // no-op @@ -19571,7 +21121,23 @@ export class UpdateCommitteeAction { } static arbitrary(prng: RandomGenerator): UpdateCommitteeAction { - throw new Error("Not Implemented"); + let gov_action_id: GovernanceActionId | undefined; + gov_action_id = GovernanceActionId.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let committee: Committee; + committee = Committee.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let members_to_remove: Credentials; + members_to_remove = Credentials.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new UpdateCommitteeAction( + gov_action_id, + committee, + members_to_remove, + ); } // no-op @@ -19711,7 +21277,19 @@ export class VRFCert { } static arbitrary(prng: RandomGenerator): VRFCert { - throw new Error("Not Implemented"); + let output: Uint8Array; + output = new Uint8Array( + repeatRand(3, prng, prand.uniformIntDistribution(0, 255))[0], + ); + prand.unsafeSkipN(prng, 1); + + let proof: Uint8Array; + proof = new Uint8Array( + repeatRand(3, prng, prand.uniformIntDistribution(0, 255))[0], + ); + prand.unsafeSkipN(prng, 1); + + return new VRFCert(output, proof); } // no-op @@ -19955,7 +21533,15 @@ export class Value { } static arbitrary(prng: RandomGenerator): Value { - throw new Error("Not Implemented"); + let coin: BigNum; + coin = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let multiasset: MultiAsset | undefined; + multiasset = MultiAsset.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new Value(coin, multiasset); } // no-op @@ -20089,7 +21675,11 @@ export class Vkey { } static arbitrary(prng: RandomGenerator): Vkey { - throw new Error("Not Implemented"); + let public_key: PublicKey; + public_key = PublicKey.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new Vkey(public_key); } // no-op @@ -20269,7 +21859,15 @@ export class Vkeywitness { } static arbitrary(prng: RandomGenerator): Vkeywitness { - throw new Error("Not Implemented"); + let vkey: Vkey; + vkey = Vkey.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let signature: Ed25519Signature; + signature = Ed25519Signature.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new Vkeywitness(vkey, signature); } // no-op @@ -20462,7 +22060,15 @@ export class VoteDelegation { } static arbitrary(prng: RandomGenerator): VoteDelegation { - throw new Error("Not Implemented"); + let stake_credential: Credential; + stake_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let drep: DRep; + drep = DRep.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new VoteDelegation(stake_credential, drep); } // no-op @@ -20588,7 +22194,19 @@ export class VoteRegistrationAndDelegation { } static arbitrary(prng: RandomGenerator): VoteRegistrationAndDelegation { - throw new Error("Not Implemented"); + let stake_credential: Credential; + stake_credential = Credential.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let drep: DRep; + drep = DRep.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let coin: BigNum; + coin = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new VoteRegistrationAndDelegation(stake_credential, drep, coin); } // no-op @@ -21055,7 +22673,15 @@ export class VotingProcedure { } static arbitrary(prng: RandomGenerator): VotingProcedure { - throw new Error("Not Implemented"); + let vote: VoteKind; + vote = VoteKind.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let anchor: Anchor | undefined; + anchor = Anchor.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new VotingProcedure(vote, anchor); } // no-op @@ -21335,7 +22961,28 @@ export class VotingProposal { } static arbitrary(prng: RandomGenerator): VotingProposal { - throw new Error("Not Implemented"); + let deposit: BigNum; + deposit = BigNum.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let reward_account: RewardAddress; + reward_account = RewardAddress.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let governance_action: GovernanceAction; + governance_action = GovernanceAction.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + let anchor: Anchor; + anchor = Anchor.arbitrary(prng); + prand.unsafeSkipN(prng, 1); + + return new VotingProposal( + deposit, + reward_account, + governance_action, + anchor, + ); } // no-op