Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flaky test fixes #462

Merged
merged 5 commits into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn init(_: ()) -> ExternResult<InitCallbackResult> {
let mut functions = BTreeSet::new();
functions.insert((
ZomeName::from("direct-message"),
"recv_send_remote_signal".into(),
"recv_remote_signal".into(),
));
functions.insert((ZomeName::from("direct-message"), "get_status".into()));
let granted_functions: GrantedFunctions = GrantedFunctions::Listed(functions);
Expand Down Expand Up @@ -117,7 +117,7 @@ pub fn get_status(_: ()) -> ExternResult<Option<PerspectiveExpression>> {
//---------------------------------------------------------

#[hdk_extern]
fn recv_send_remote_signal(signal: SerializedBytes) -> ExternResult<()> {
fn recv_remote_signal(signal: SerializedBytes) -> ExternResult<()> {
debug!("RECEIVEING MESSAGE...");
match PerspectiveExpression::try_from(signal) {
Ok(message) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ fn init(_: ()) -> ExternResult<InitCallbackResult> {
let mut functions = BTreeSet::new();
functions.insert((zome_info()?.name, "get_online_status".into()));
//TODO; is this next function needed?
functions.insert((zome_info()?.name, "recv_send_remote_signal".into()));
functions.insert((zome_info()?.name, "recv_remote_signal".into()));

let functions: GrantedFunctions = GrantedFunctions::Listed(functions);

Expand Down Expand Up @@ -97,7 +97,7 @@ pub fn update_current_revision(_hash: Hash) -> ExternResult<()> {
/// Signal handling

#[hdk_extern]
fn recv_send_remote_signal(signal: SerializedBytes) -> ExternResult<()> {
fn recv_remote_signal(signal: SerializedBytes) -> ExternResult<()> {
//Check if its a normal diff expression signal
match HashBroadcast::try_from(signal.clone()) {
Ok(broadcast) => {
Expand Down
8 changes: 3 additions & 5 deletions rust-executor/src/holochain_service/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ impl HolochainService {
// staging - https://bootstrap-staging.holo.host
// dev - https://bootstrap-dev.holohost.workers.dev
// own - http://207.148.16.17:38245
kitsune_config.bootstrap_service = Some(Url2::parse(String::from("https://bootstrap.holo.host/")));
kitsune_config.bootstrap_service = Some(Url2::parse(local_config.bootstrap_url));
} else {
kitsune_config.bootstrap_service = None;
}
Expand All @@ -365,7 +365,7 @@ impl HolochainService {
// prod - wss://signal.holo.host
// dev - wss://signal.holotest.net
// our - ws://207.148.16.17:42697
signal_url: String::from("wss://signal.holo.host"),
signal_url: local_config.proxy_url,
}];
} else {
kitsune_config.transport_pool = vec![
Expand All @@ -377,8 +377,6 @@ impl HolochainService {
}
config.network = kitsune_config;

println!("wow 1 {:?}", config);

config
};

Expand Down Expand Up @@ -598,7 +596,7 @@ impl HolochainService {

let stats = self.conductor.dump_network_stats().await?;
info!("Network stats: {}", stats);

Ok(())
}

Expand Down
6 changes: 3 additions & 3 deletions tests/js/tests/agent-language.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import { expect } from "chai";

export default function agentLanguageTests(testContext: TestContext) {
return () => {
it.skip("works across remote agents", async () => {
it("works across remote agents", async () => {
const alice = testContext.alice!
const didAlice = (await alice.agent.status()).did!
const bob = testContext.bob!
const bob = testContext.bob!
const didBob = (await bob.agent.status()).did!

const aliceHerself = await alice.agent.me()
Expand All @@ -22,6 +22,6 @@ export default function agentLanguageTests(testContext: TestContext) {
const aliceSeenFromBob = await bob.agent.byDID(didAlice)
expect(aliceSeenFromBob).not.to.be.undefined
expect(aliceSeenFromBob).to.be.eql(aliceHerself)
})
})
}
}
14 changes: 7 additions & 7 deletions tests/js/tests/direct-messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function directMessageTests(testContext: TestContext) {
link.author = "did:test";
link.timestamp = new Date().toISOString();
link.data = new Link({
source: Literal.from("me").toUrl(),
source: Literal.from("me").toUrl(),
predicate: Literal.from("thinks").toUrl(),
target: Literal.from("nothing").toUrl()
});
Expand All @@ -28,11 +28,11 @@ export default function directMessageTests(testContext: TestContext) {
}catch(e) {
hasThrown = true
}

expect(hasThrown).to.be.true;
})
})

describe.skip("with Alice and Bob being friends", () => {
describe("with Alice and Bob being friends", () => {
//@ts-ignore
let alice, bob, didAlice, didBob

Expand All @@ -52,15 +52,15 @@ export default function directMessageTests(testContext: TestContext) {
link.timestamp = new Date().toISOString();
link.data = new Link({
//@ts-ignore
source: didBob,
source: didBob,
predicate: Literal.from("is").toUrl(),
target: Literal.from("online").toUrl()
});
link.proof = new ExpressionProof("sig", "key");
const statusBob = new Perspective([link])
//@ts-ignore
await bob.runtime.setStatus(statusBob)
await sleep(1000)
await sleep(1000)
//@ts-ignore
const statusAlice = await alice.runtime.friendStatus(didBob)
expect(statusAlice).not.to.be.undefined;
Expand Down Expand Up @@ -91,7 +91,7 @@ export default function directMessageTests(testContext: TestContext) {
expect((await bob.runtime.messageInbox(didAlice)).length).to.be.equal(1)
//@ts-ignore
expect((await bob.runtime.messageInbox("did:test:other")).length).to.be.equal(0)

})

it("Alice finds her sent message in the outbox", async () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/js/tests/integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ describe("Integration tests", function () {

await testContext.bob.agent.updatePublicPerspective(new Perspective([link]))

//await testContext.makeAllNodesKnown()
await testContext.makeAllNodesKnown()
})

after(async () => {
Expand Down
30 changes: 15 additions & 15 deletions tests/js/tests/neighbourhood.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ let bobP1: null | PerspectiveHandle = null;

export default function neighbourhoodTests(testContext: TestContext) {
return () => {
describe.skip('Neighbourhood', () => {
describe('Neighbourhood', () => {
it('can publish and join locally @alice', async () => {
const ad4mClient = testContext.alice!;

Expand All @@ -29,7 +29,7 @@ export default function neighbourhoodTests(testContext: TestContext) {
link.timestamp = new Date().toISOString();
link.data = new Link({source: "src", target: "target", predicate: "pred"});
link.proof = new ExpressionProof("sig", "key");
const publishPerspective = await ad4mClient.neighbourhood.publishFromPerspective(create.uuid, socialContext.address,
const publishPerspective = await ad4mClient.neighbourhood.publishFromPerspective(create.uuid, socialContext.address,
new Perspective(
[link]
)
Expand All @@ -53,19 +53,19 @@ export default function neighbourhoodTests(testContext: TestContext) {
const socialContext = await alice.languages.applyTemplateAndPublish(DIFF_SYNC_OFFICIAL, JSON.stringify({uid: uuidv4(), name: "Alice's neighbourhood with Bob"}));
expect(socialContext.name).to.be.equal("Alice's neighbourhood with Bob");
const neighbourhoodUrl = await alice.neighbourhood.publishFromPerspective(aliceP1.uuid, socialContext.address, new Perspective())

let bobP1 = await bob.neighbourhood.joinFromUrl(neighbourhoodUrl);

await testContext.makeAllNodesKnown()

expect(bobP1!.name).not.to.be.undefined;
expect(bobP1!.sharedUrl).to.be.equal(neighbourhoodUrl)
expect(bobP1!.neighbourhood).not.to.be.undefined;;
expect(bobP1!.neighbourhood!.data.linkLanguage).to.be.equal(socialContext.address);
expect(bobP1!.neighbourhood!.data.meta.links.length).to.be.equal(0);
})
it.skip('shared link created by Alice received by Bob', async () => {

it('shared link created by Alice received by Bob', async () => {
const alice = testContext.alice
const bob = testContext.bob

Expand Down Expand Up @@ -93,7 +93,7 @@ export default function neighbourhoodTests(testContext: TestContext) {
bobLinks = await bob.perspective.queryLinks(bobP1!.uuid, new LinkQuery({source: 'root'}))
tries++
}

expect(bobLinks.length).to.be.equal(1)
expect(bobLinks[0].data.target).to.be.equal('test://test')
expect(bobLinks[0].proof.valid).to.be.true;
Expand Down Expand Up @@ -127,7 +127,7 @@ export default function neighbourhoodTests(testContext: TestContext) {
bobLinks = await bob.perspective.queryLinks(bobP1!.uuid, new LinkQuery({source: 'root'}))
tries++
}

expect(bobLinks.length).to.be.equal(0)
})

Expand All @@ -143,7 +143,7 @@ export default function neighbourhoodTests(testContext: TestContext) {

const perspectives = await alice.perspective.all();
})

// it('can get the correct state change signals', async () => {
// const aliceP1 = await testContext.alice.perspective.add("state-changes")
// expect(aliceP1.state).to.be.equal(PerspectiveState.Private);
Expand Down Expand Up @@ -221,7 +221,7 @@ export default function neighbourhoodTests(testContext: TestContext) {
const bobP1Handle = await bob.neighbourhood.joinFromUrl(neighbourhoodUrl);
const bobP1 = await bob.perspective.byUUID(bobP1Handle.uuid)
await testContext.makeAllNodesKnown()

aliceNH = aliceP1.getNeighbourhoodProxy()
bobNH = bobP1!.getNeighbourhoodProxy()
aliceDID = (await alice.agent.me()).did
Expand Down Expand Up @@ -259,15 +259,15 @@ export default function neighbourhoodTests(testContext: TestContext) {
expect(aliceOnline[0].did).to.be.equal(bobDID)
console.log(aliceOnline[0].status);
expect(aliceOnline[0].status.data.links).to.deep.equal(testPerspective.links)

expect(bobOnline.length).to.be.equal(1)
expect(bobOnline[0].did).to.be.equal(aliceDID)
expect(bobOnline[0].status.data.links).to.deep.equal(testPerspective.links)


await aliceNH!.setOnlineStatusU(PerspectiveUnsignedInput.fromLink(new Link({
source: "test://source",
target: "test://target"
target: "test://target"
})))

const bobOnline2 = await bobNH!.onlineAgents()
Expand All @@ -280,7 +280,7 @@ export default function neighbourhoodTests(testContext: TestContext) {
// TODO: Signature check for the whole perspective is broken
// Got to fix that and add back this assertion
//expect(bobOnline2[0].status.proof.valid).to.be.true

})

it('they can send signals via `sendSignal` and receive callbacks via `addSignalHandler`', async () => {
Expand Down Expand Up @@ -321,7 +321,7 @@ export default function neighbourhoodTests(testContext: TestContext) {
//@ts-ignore
expect(bobData.data.links).to.deep.equal(aliceSignal.links)


let link2 = new Link({source: "bob", target: "alice", predicate: "signal"});
const bobSignal = new PerspectiveUnsignedInput([link2])

Expand Down
22 changes: 11 additions & 11 deletions tests/js/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ export async function isProcessRunning(processName: string): Promise<boolean> {
})()

if (!cmd) throw new Error("Invalid OS");

return new Promise((resolve, reject) => {
//@ts-ignore
exec(cmd, (err: ExecException, stdout: string, stderr: string) => {
if (err) reject(err)

resolve(stdout.toLowerCase().indexOf(processName.toLowerCase()) > -1)
})
})
})
}

export async function runHcLocalServices(): Promise<{proxyUrl: string | null, bootstrapUrl: string | null, process: ChildProcess}> {
Expand Down Expand Up @@ -61,8 +61,8 @@ export async function runHcLocalServices(): Promise<{proxyUrl: string | null, bo
return {proxyUrl, bootstrapUrl, process: servicesProcess};
}

export async function startExecutor(dataPath: string,
bootstrapSeedPath: string,
export async function startExecutor(dataPath: string,
bootstrapSeedPath: string,
gqlPort: number,
hcAdminPort: number,
hcAppPort: number,
Expand All @@ -78,15 +78,15 @@ export async function startExecutor(dataPath: string,
let executorProcess = null as ChildProcess | null;
rmSync(dataPath, { recursive: true, force: true })
execSync(`${command} init --data-path ${dataPath} --network-bootstrap-seed ${bootstrapSeedPath}`, {cwd: process.cwd()})

console.log("Starting executor")

console.log("USING LOCAL BOOTSTRAP & PROXY URL: ", bootstrapUrl, proxyUrl);

if (!adminCredential) {
executorProcess = exec(`${command} run --app-data-path ${dataPath} --gql-port ${gqlPort} --hc-admin-port ${hcAdminPort} --hc-app-port ${hcAppPort} --hc-proxy-url ${proxyUrl} --hc-bootstrap-url ${bootstrapUrl} --hc-use-bootstrap false --hc-use-proxy true --hc-use-local-proxy true --hc-use-mdns true --language-language-only ${languageLanguageOnly} --run-dapp-server false`, {})
executorProcess = exec(`${command} run --app-data-path ${dataPath} --gql-port ${gqlPort} --hc-admin-port ${hcAdminPort} --hc-app-port ${hcAppPort} --hc-proxy-url ${proxyUrl} --hc-bootstrap-url ${bootstrapUrl} --hc-use-bootstrap true --hc-use-proxy true --hc-use-local-proxy true --hc-use-mdns true --language-language-only ${languageLanguageOnly} --run-dapp-server false`, {})
} else {
executorProcess = exec(`${command} run --app-data-path ${dataPath} --gql-port ${gqlPort} --hc-admin-port ${hcAdminPort} --hc-app-port ${hcAppPort} --hc-proxy-url ${proxyUrl} --hc-bootstrap-url ${bootstrapUrl} --hc-use-bootstrap false --hc-use-proxy true --hc-use-local-proxy true --hc-use-mdns true --language-language-only ${languageLanguageOnly} --admin-credential ${adminCredential} --run-dapp-server false`, {})
executorProcess = exec(`${command} run --app-data-path ${dataPath} --gql-port ${gqlPort} --hc-admin-port ${hcAdminPort} --hc-app-port ${hcAppPort} --hc-proxy-url ${proxyUrl} --hc-bootstrap-url ${bootstrapUrl} --hc-use-bootstrap true --hc-use-proxy true --hc-use-local-proxy true --hc-use-mdns true --language-language-only ${languageLanguageOnly} --admin-credential ${adminCredential} --run-dapp-server false`, {})
}
let executorReady = new Promise<void>((resolve, reject) => {
executorProcess!.stdout!.on('data', (data) => {
Expand All @@ -98,7 +98,7 @@ export async function startExecutor(dataPath: string,
if (data.includes(`listening on http://127.0.0.1:${gqlPort}`)) {
resolve()
}
});
});
})

executorProcess!.stdout!.on('data', (data) => {
Expand All @@ -109,7 +109,7 @@ export async function startExecutor(dataPath: string,
});

console.log("Waiting for executor to settle...")
await executorReady
await executorReady
return executorProcess;
}

Expand Down Expand Up @@ -149,7 +149,7 @@ export function apolloClient(port: number, token?: string): ApolloClient<any> {
}
},
});

return client;
}

Expand Down