Skip to content

Commit

Permalink
Bump Canton and reenable tests (digital-asset#12852)
Browse files Browse the repository at this point in the history
* Bump Canton and reenable tests

fixes digital-asset#12808

changelog_begin
changelog_end

* display names are no longer defaulted

changelog_begin
changelog_end

* topology-change-delay is redundant

changelog_begin
changelog_end

* Switch away from grpcurl

changelog_begin
changelog_end

* try to fix canton conformance tests

changelog_begin
changelog_end

* that’s not how you scala

changelog_begin
changelog_end
  • Loading branch information
cocreature authored Feb 10, 2022
1 parent f279779 commit 8b8ee4c
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 73 deletions.
5 changes: 0 additions & 5 deletions daml-assistant/daml-helper/src/DA/Daml/Helper/Util.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
]
)
]
]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)
8 changes: 8 additions & 0 deletions ledger/ledger-api-test-tool-on-canton/bootstrap.canton
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
import com.digitalasset.canton.time.NonNegativeFiniteDuration

nodes.local start

test_domain.service.update_dynamic_parameters(_.copy(
ledgerTimeRecordTimeTolerance = NonNegativeFiniteDuration.ofMinutes(3),
mediatorReactionTimeout = NonNegativeFiniteDuration.ofMinutes(1),
participantResponseTimeout = NonNegativeFiniteDuration.ofMinutes(1),
))

participants.local foreach (_.domains.connect_local(test_domain))

utils.retry_until_true {
Expand Down
3 changes: 0 additions & 3 deletions ledger/ledger-api-test-tool-on-canton/canton.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
84 changes: 22 additions & 62 deletions templates/create-daml-app-test-resources/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand All @@ -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 {
Expand Down Expand Up @@ -232,10 +217,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.
Expand Down Expand Up @@ -269,10 +251,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();
Expand Down Expand Up @@ -360,10 +339,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();

Expand All @@ -378,10 +354,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();
Expand Down Expand Up @@ -432,26 +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);

// 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 = [
"-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/);
Expand Down

0 comments on commit 8b8ee4c

Please sign in to comment.