From d2e5a0562028145b1a67c84137d7464e40562c57 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 9 Feb 2022 17:09:37 +0100 Subject: [PATCH 1/6] Bump Canton and reenable tests fixes #12808 changelog_begin changelog_end --- deps.bzl | 4 +-- .../index.test.ts | 25 ++++--------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/deps.bzl b/deps.bzl index 13c482fa164c..ae0e512e102a 100644 --- a/deps.bzl +++ b/deps.bzl @@ -356,7 +356,7 @@ java_import( jars = glob(["lib/**/*.jar"]), ) """, - sha256 = "529bcb185b0fec8e74652a7589b37c22f5700d765edd2467375655eb3e656c29", + sha256 = "e72c2ecd613a868ec3eb5654258527cbaed17b15b8c260a0a3de49841355af12", strip_prefix = "canton-community-1.0.0-SNAPSHOT", - urls = ["https://www.canton.io/releases/canton-community-20220202.tar.gz"], + urls = ["https://www.canton.io/releases/canton-community-20220209.tar.gz"], ) diff --git a/templates/create-daml-app-test-resources/index.test.ts b/templates/create-daml-app-test-resources/index.test.ts index c088b9558811..9c262b13bd06 100644 --- a/templates/create-daml-app-test-resources/index.test.ts +++ b/templates/create-daml-app-test-resources/index.test.ts @@ -232,10 +232,7 @@ const follow = async (page: Page, userToFollow: string) => { } // LOGIN_TEST_BEGIN -// FIXME Enable this test once the integration test can be run against a version of Canton that supports the new interface for creating a user -// FIXME The change was introduced as part of https://github.com/digital-asset/daml/pull/12682 -// FIXME The ticket tracking this issue is https://github.com/digital-asset/daml/issues/12808 -test.skip('log in as a new user, log out and log back in', async () => { +test('log in as a new user, log out and log back in', async () => { const [user, party] = await getParty(); // Log in as a new user. @@ -269,10 +266,7 @@ test.skip('log in as a new user, log out and log back in', async () => { // - while the user that is followed is logged out // These are all successful cases. -// FIXME Enable this test once the integration test can be run against a version of Canton that supports the new interface for creating a user -// FIXME The change was introduced as part of https://github.com/digital-asset/daml/pull/12682 -// FIXME The ticket tracking this issue is https://github.com/digital-asset/daml/issues/12808 -test.skip('log in as three different users and start following each other', async () => { +test('log in as three different users and start following each other', async () => { const [user1, party1] = await getParty(); const [user2, party2] = await getParty(); const [user3, party3] = await getParty(); @@ -360,10 +354,7 @@ test.skip('log in as three different users and start following each other', asyn await page3.close(); }, 60_000); -// FIXME Enable this test once the integration test can be run against a version of Canton that supports the new interface for creating a user -// FIXME The change was introduced as part of https://github.com/digital-asset/daml/pull/12682 -// FIXME The ticket tracking this issue is https://github.com/digital-asset/daml/issues/12808 -test.skip('error when following self', async () => { +test('error when following self', async () => { const [user, party] = await getParty(); const page = await newUiPage(); @@ -378,10 +369,7 @@ test.skip('error when following self', async () => { await page.close(); }); -// FIXME Enable this test once the integration test can be run against a version of Canton that supports the new interface for creating a user -// FIXME The change was introduced as part of https://github.com/digital-asset/daml/pull/12682 -// FIXME The ticket tracking this issue is https://github.com/digital-asset/daml/issues/12808 -test.skip('error when adding a user that you are already following', async () => { +test('error when adding a user that you are already following', async () => { const [user1, party1] = await getParty(); const [user2, party2] = await getParty(); const page = await newUiPage(); @@ -436,10 +424,7 @@ test('error on non-existent user id', async () => { await page.close(); }, 40_000); -// FIXME Enable this test once the integration test can be run against a version of Canton that supports the new interface for creating a user -// FIXME The change was introduced as part of https://github.com/digital-asset/daml/pull/12682 -// FIXME The ticket tracking this issue is https://github.com/digital-asset/daml/issues/12808 -test.skip('error on user with no primary party', async () => { +test('error on user with no primary party', async () => { const invalidUser = "noprimary"; // TODO replace with daml-ledger once it exposes the create user endpoint. const grpcurlUserArgs = [ From 670521538fd807c821765be48c8ee339f27df46c Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 9 Feb 2022 18:21:29 +0100 Subject: [PATCH 2/6] display names are no longer defaulted changelog_begin changelog_end --- .../integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daml-assistant/integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs b/daml-assistant/integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs index 82ba76917948..04240152da21 100644 --- a/daml-assistant/integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs +++ b/daml-assistant/integration-tests/src/DA/Daml/Assistant/IntegrationTests.hs @@ -594,7 +594,7 @@ damlStartNotSharedTest = testCase "daml start --sandbox-port=0" $ queryResponse <- httpLbs queryRequest manager let body = responseBody queryResponse assertBool ("result is unexpected: " <> show body) $ - ("{\"result\":{\"displayName\":\"Alice\",\"identifier\":\"Alice::" `LBS.isPrefixOf` body) && + ("{\"result\":{\"identifier\":\"Alice::" `LBS.isPrefixOf` body) && ("\",\"isLocal\":true},\"status\":200}" `LBS.isSuffixOf` body) quickstartTests :: FilePath -> FilePath -> IO QuickSandboxResource -> TestTree From b6844924fbfe7bc06001576a9d61219c2a6371a0 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 9 Feb 2022 18:42:59 +0100 Subject: [PATCH 3/6] topology-change-delay is redundant changelog_begin changelog_end --- daml-assistant/daml-helper/src/DA/Daml/Helper/Util.hs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/daml-assistant/daml-helper/src/DA/Daml/Helper/Util.hs b/daml-assistant/daml-helper/src/DA/Daml/Helper/Util.hs index 42eb58c4e5c6..81e156542854 100644 --- a/daml-assistant/daml-helper/src/DA/Daml/Helper/Util.hs +++ b/daml-assistant/daml-helper/src/DA/Daml/Helper/Util.hs @@ -312,15 +312,10 @@ cantonConfig CantonOptions{..} = ] , "domains" Aeson..= Aeson.object [ "local" Aeson..= Aeson.object - ( [ storage , "public-api" Aeson..= port cantonDomainPublicApi , "admin-api" Aeson..= port cantonDomainAdminApi - ] <> - [ "domain-parameters" Aeson..= Aeson.object [ "topology-change-delay" Aeson..= ("0 ms" :: T.Text) ] - | StaticTime True <- [cantonStaticTime] ] - ) ] ] ] From 56c9bf1f467a0ec113b23b0d41878f9d1cf11975 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 9 Feb 2022 22:11:00 +0100 Subject: [PATCH 4/6] Switch away from grpcurl changelog_begin changelog_end --- .../index.test.ts | 59 ++++++------------- 1 file changed, 17 insertions(+), 42 deletions(-) diff --git a/templates/create-daml-app-test-resources/index.test.ts b/templates/create-daml-app-test-resources/index.test.ts index 9c262b13bd06..0bcfb496d0a6 100644 --- a/templates/create-daml-app-test-resources/index.test.ts +++ b/templates/create-daml-app-test-resources/index.test.ts @@ -8,7 +8,7 @@ import { promises as fs } from 'fs'; import puppeteer, { Browser, Page } from 'puppeteer'; import waitOn from 'wait-on'; -import Ledger from '@daml/ledger'; +import Ledger, { UserRightHelper } from '@daml/ledger'; import { User } from '@daml.js/create-daml-app'; import { authConfig } from './config'; @@ -25,46 +25,31 @@ let uiProc: ChildProcess | undefined = undefined; // Chrome browser that we run in headless mode let browser: Browser | undefined = undefined; -let publicUser: string = ''; -let publicParty: string = ''; +let publicUser: string | undefined; +let publicParty: string | undefined; + +const adminLedger = new Ledger({token: authConfig.makeToken("participant_admin")}); // Function to generate unique party names for us. let nextPartyId = 1; const getParty = async () : [string, string] => { - // TODO For now we use grpcurl to allocate parties and users. - // Once the JSON API exposes party & user management we can switch to that. - const grpcurlPartyArgs = [ - "-plaintext", - "localhost:6865", - "com.daml.ledger.api.v1.admin.PartyManagementService/AllocateParty", - ]; - const allocResult = spawnSync('grpcurl', grpcurlPartyArgs, {"encoding": "utf8"}); - const parsedResult = JSON.parse(allocResult.stdout); + const allocResult = await adminLedger.allocateParty({}); const user = `u${nextPartyId}`; - const party = parsedResult.partyDetails.party; - const createUser = { - "user": { - "id": user, - "primary_party": party, - }, - "rights": [{"can_act_as": {"party": party}}, {"can_read_as": {"party": publicParty}}] - }; - const grpcurlUserArgs = [ - "-plaintext", - "-d", - JSON.stringify(createUser), - "localhost:6865", - "com.daml.ledger.api.v1.admin.UserManagementService/CreateUser", - ]; - const result = spawnSync('grpcurl', grpcurlUserArgs, {"encoding": "utf8"}); + const party = allocResult.identifier; + const rights: UserRight[] = [UserRightHelper.canActAs(party)].concat(publicParty !== undefined ? [UserRightHelper.canReadAs(publicParty)] : []); + await adminLedger.createUser(user, rights, party); nextPartyId++; return [user, party]; }; test('Party names are unique', async () => { - const parties = new Set(await Promise.all(Array(10).fill({}).map(() => getParty()))); + let r = []; + for (let i = 0; i < 10; ++i) { + r = r.concat((await getParty())[1]); + } + const parties = new Set(r); expect(parties.size).toEqual(10); -}); +}, 20_000); const removeFile = async (path: string) => { try { @@ -420,23 +405,13 @@ test('error on non-existent user id', async () => { const invalidUser = "nonexistent"; const page = await newUiPage(); const error = await failedLogin(page, invalidUser); - expect(error).toMatch(/cannot get user for unknown user \\"nonexistent\\"/); + expect(error).toMatch(/getting user failed for unknown user \\"nonexistent\\"/); await page.close(); }, 40_000); test('error on user with no primary party', async () => { const invalidUser = "noprimary"; - // TODO replace with daml-ledger once it exposes the create user endpoint. - const grpcurlUserArgs = [ - "-plaintext", - "-d", - JSON.stringify({"user": {"id": invalidUser}}), - "localhost:6865", - "com.daml.ledger.api.v1.admin.UserManagementService/CreateUser", - ]; - const result = spawnSync('grpcurl', grpcurlUserArgs, {"encoding": "utf8"}); - console.debug(result.stdout); - console.debug(result.stderr); + await adminLedger.createUser(invalidUser, []); const page = await newUiPage(); const error = await failedLogin(page, invalidUser); expect(error).toMatch(/User 'noprimary' has no primary party/); From a23a3bcf607753ff1d67197671a126bcfc9295fe Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 9 Feb 2022 22:20:47 +0100 Subject: [PATCH 5/6] try to fix canton conformance tests changelog_begin changelog_end --- ledger/ledger-api-test-tool-on-canton/bootstrap.canton | 6 ++++++ ledger/ledger-api-test-tool-on-canton/canton.conf | 3 --- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/ledger/ledger-api-test-tool-on-canton/bootstrap.canton b/ledger/ledger-api-test-tool-on-canton/bootstrap.canton index a9d1e530950d..d1666922ae4e 100644 --- a/ledger/ledger-api-test-tool-on-canton/bootstrap.canton +++ b/ledger/ledger-api-test-tool-on-canton/bootstrap.canton @@ -1,5 +1,11 @@ nodes.local start +test_domain.service.update_dynamic_parameters(_.copy( + ledgerTimeRecordTimeTolerance = 3m, + mediatorReactionTimeout = 1m, + participantResponseTimeout = 1m, +)) + participants.local foreach (_.domains.connect_local(test_domain)) utils.retry_until_true { diff --git a/ledger/ledger-api-test-tool-on-canton/canton.conf b/ledger/ledger-api-test-tool-on-canton/canton.conf index 299e396cefb9..d8c65c7bd8bc 100644 --- a/ledger/ledger-api-test-tool-on-canton/canton.conf +++ b/ledger/ledger-api-test-tool-on-canton/canton.conf @@ -15,9 +15,6 @@ canton { admin-api.port = 4012 domain-parameters { - participant-response-timeout = 1m - ledger-time-record-time-tolerance = 3m - mediator-reaction-timeout = 1m max-rate-per-participant = 10000 } } From 0c47e0edb6d4033bf53aaf3aa44821707b29ce48 Mon Sep 17 00:00:00 2001 From: Moritz Kiefer Date: Wed, 9 Feb 2022 22:29:12 +0100 Subject: [PATCH 6/6] =?UTF-8?q?that=E2=80=99s=20not=20how=20you=20scala?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit changelog_begin changelog_end --- ledger/ledger-api-test-tool-on-canton/bootstrap.canton | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/ledger/ledger-api-test-tool-on-canton/bootstrap.canton b/ledger/ledger-api-test-tool-on-canton/bootstrap.canton index d1666922ae4e..bd3f060c1aae 100644 --- a/ledger/ledger-api-test-tool-on-canton/bootstrap.canton +++ b/ledger/ledger-api-test-tool-on-canton/bootstrap.canton @@ -1,9 +1,11 @@ +import com.digitalasset.canton.time.NonNegativeFiniteDuration + nodes.local start test_domain.service.update_dynamic_parameters(_.copy( - ledgerTimeRecordTimeTolerance = 3m, - mediatorReactionTimeout = 1m, - participantResponseTimeout = 1m, + ledgerTimeRecordTimeTolerance = NonNegativeFiniteDuration.ofMinutes(3), + mediatorReactionTimeout = NonNegativeFiniteDuration.ofMinutes(1), + participantResponseTimeout = NonNegativeFiniteDuration.ofMinutes(1), )) participants.local foreach (_.domains.connect_local(test_domain))