Error about party allocation without connected domain with DAML Version >= 2.1.0 in unit test

Hello,
I’m following up from Running DAZL tests in Github Presubmit (Also with bazel) (sorry to ask so many follow-ups), but I believe I am pretty close to what we want.
Currently, we generate the SDK in our buildrule and add the path into the environment where the testing.sandbox gets setup. That allows us to successfully run DAML without installing it directly into the machine.
However, I noticed that when we use version 2.1.0 or higher as our test:
as with the line:

with testing.sandbox(project_root=None, version='2.1.0') as sb:

we get an error:

details = "PARTY_ALLOCATION_WITHOUT_CONNECTED_DOMAIN(9,849df599): Cannot allocate a party without being connected to a domain"

when we run:

    async with dazl.connect(url=sandbox_url, admin=True) as conn:
        with open(dar_path(), 'rb') as dar_file:
            party1,party2, _ = await asyncio.gather(conn.allocate_party(), conn.allocate_party(), conn.upload_package(dar_file.read()))

Do you know why that may be the case? Is there a new kind of setup we need to do for version 2.1.0 or higher?
I saw a note about it in Release canton v2.1.0 · digital-asset/canton · GitHub, but I didn’t know how to parse that…

Thank you!

Edit: Alternatively, all I’m doing there right now is copying what we are doing in our Setup.daml, which is our initialization script for our ledger. If we can run that in the test (uploading the dar file doesn’t seem to run it?) And get our party from it, I think that would work as well…

Unfortunately for newer versions of the sandbox, the port is opened slightly before the sandbox is actually ready for party allocation commands.

This will be addressed in a future version of dazl by fully waiting for the appropriate API to come available before yielding control back to the caller; until then, asyncio.sleep(2) should do the trick. :-/

Oh, that is good to know, thank you.

This has been addressed in dazl 7.7.6, so if you upgrade to the latest version (now 7.8.0), you no longer need the sleep workaround.

Good to know, thank you!