G-d willing
Hello,
I wrote this small java class that creates a proposal contract, followed by validating that the contract exists.
@QuarkusTest
public class RentApp {
public static final String DAML_FOLDER = "./";
public static final String DAR_FOLDER = "./.daml/dist/java-binding-0.0.1.dar";
public static final Path DAML_ROOT = Path.of(DAML_FOLDER).toAbsolutePath();
public static final String TEST_MODULE = "Main";
public static final String TEST_START_SCRIPT = "initializeScript";
public static final String CUSTOM_PORT = "6865";
public static final Integer SANDBOX_WAIT_TIMEOUT = 18000;
public static final Integer OBSERVATION_TIMEOUT = 0;
public static final String[] PARTIES = new String [] {};
public static final Path DAR_PATH = Path.of(DAR_FOLDER).toAbsolutePath();
public static final BiConsumer<DamlLedgerClient, ManagedChannel> SETUP_APPLICATION = (Client, Channel) -> {};
public static final Boolean USE_WALLCLOCK_TIME = Boolean.FALSE;
protected static final SandboxManager sandbox = new SandboxManager(
DAML_ROOT, Optional.of(TEST_MODULE), Optional.of(TEST_START_SCRIPT), Optional.of(Integer.parseInt(CUSTOM_PORT)),
Duration.ofSeconds(SANDBOX_WAIT_TIMEOUT), Duration.ofSeconds(OBSERVATION_TIMEOUT),
PARTIES, DAR_PATH, SETUP_APPLICATION, USE_WALLCLOCK_TIME);
@BeforeAll
public static void ConnectToSandbox() throws TimeoutException, IOException, InterruptedException {
sandbox.start();
}
@Test
public void testRentProposalContractWasCreated (){
Party landlord = sandbox.getPartyId("Alice");
Party tenant = sandbox.getPartyId("Bob");
DamlRecord rentProposalRecord = record(
field("landlord", landlord),
field("tenant", tenant),
field("terms", text("some terms"))
);
sandbox.getLedgerAdapter().createContract(landlord, RentProposal.TEMPLATE_ID, rentProposalRecord);
RentProposal.ContractId rentProposalContractId = sandbox.getLedgerAdapter().
getCreatedContractId(landlord, RentProposal.TEMPLATE_ID, RentProposal.ContractId::new);
}
@AfterAll
public static void stopTheSandbox() {
sandbox.stop();
}
}
However, the test fails to indicate the following:
Expected:
Identifier{packageId='ff575e916a57ab6a9e853c6623d5fc1e8b7a911b3488d83c4e41e35db8a714e0', moduleName='Main', entityName='RentProposal'} - {CAPTURE:internal-cid-query}
But no events observed via ledger channel
If there were a problem with the daml code, I would expect to the first command, which uses createContract
, to fail. However, the error comes from the line that comes afterward, using the getCreatedContractId
command. How is it possible to succeed in creating the contract but failing to find it right away? Can you see what am I doing wrong?
Here is a screenshot from the error report: