Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zo-el committed Nov 9, 2021
1 parent 021a8a5 commit f7c08f2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
3 changes: 1 addition & 2 deletions tests/src/basic-chatting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as _ from 'lodash'
import { v4 as uuidv4 } from "uuid";
import { localConductorConfig, delay } from './common'
import { installAgents } from './installAgents'
import { getTimestamp } from './utils'

module.exports = async (orchestrator) => {

Expand Down Expand Up @@ -75,7 +74,7 @@ module.exports = async (orchestrator) => {

// Alice lists the messages
var msgs: any[] = [];
let batch_payload = { channel: channel.entry, active_chatter: false, earlier_than: getTimestamp(), target_message_count: 2 }
let batch_payload = { channel: channel.entry, active_chatter: false, target_message_count: 2 }
msgs.push(await alice_chat.call('chat', 'list_messages', batch_payload));
console.log(_.map(msgs[0].messages, messageEntry));
t.deepEqual([sends[0].entry, sends[1].entry], _.map(msgs[0].messages, messageEntry));
Expand Down
17 changes: 9 additions & 8 deletions tests/src/pagination.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as _ from 'lodash'
import { v4 as uuidv4 } from "uuid";
import { localConductorConfig, delay, awaitIntegration } from './common'
import { installAgents } from './installAgents'
import { getTimestamp } from './utils'

module.exports = async (orchestrator) => {

Expand Down Expand Up @@ -75,17 +74,17 @@ module.exports = async (orchestrator) => {
await awaitIntegration(bobbo_chat)

// Alice lists the messages
let alices_view = await alice_chat.call('chat', 'list_messages', { channel: channel.entry, active_chatter: false, earlier_than: getTimestamp(), target_message_count: 2 })
let alices_view = await alice_chat.call('chat', 'list_messages', { channel: channel.entry, active_chatter: false, target_message_count: 2 })

let bobbos_view = await bobbo_chat.call('chat', 'list_messages', { channel: channel.entry, active_chatter: false, earlier_than: getTimestamp(), target_message_count: 2 })
let bobbos_view = await bobbo_chat.call('chat', 'list_messages', { channel: channel.entry, active_chatter: false, target_message_count: 2 })

if (alices_view.messages.length !== 2) {
await delay(10000)
console.log("Trying again...");

alices_view = await alice_chat.call('chat', 'list_messages', { channel: channel.entry, active_chatter: false, earlier_than: getTimestamp(), target_message_count: 2 })
alices_view = await alice_chat.call('chat', 'list_messages', { channel: channel.entry, active_chatter: false, target_message_count: 2 })

bobbos_view = await bobbo_chat.call('chat', 'list_messages', { channel: channel.entry, active_chatter: false, earlier_than: getTimestamp(), target_message_count: 2 })
bobbos_view = await bobbo_chat.call('chat', 'list_messages', { channel: channel.entry, active_chatter: false, target_message_count: 2 })
}
t.deepEqual(alices_view.messages.length, 2)
t.deepEqual(bobbos_view.messages.length, 2)
Expand Down Expand Up @@ -116,12 +115,14 @@ module.exports = async (orchestrator) => {
t.deepEqual(sends[3].entry, recvs[3].entry);
await delay(4000)
// Alice lists the messages
alices_view = await alice_chat.call('chat', 'list_messages', { channel: channel.entry, active_chatter: false, earlier_than: getTimestamp(), target_message_count: 20 })
alices_view = await alice_chat.call('chat', 'list_messages', { channel: channel.entry, active_chatter: false, target_message_count: 20 })
// Bobbo lists the messages
bobbos_view = await bobbo_chat.call('chat', 'list_messages', { channel: channel.entry, active_chatter: false, earlier_than: getTimestamp(), target_message_count: 10 })
bobbos_view = await bobbo_chat.call('chat', 'list_messages', { channel: channel.entry, active_chatter: false, target_message_count: 10 })
t.deepEqual(alices_view.messages.length, 4)
t.deepEqual(bobbos_view.messages.length, 4)

console.log("ALICE ", alices_view);
console.log("BOBBO: ", bobbos_view);

})

}
3 changes: 1 addition & 2 deletions tests/src/transient-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import * as _ from 'lodash'
import { v4 as uuidv4 } from "uuid";
import { RETRY_DELAY, RETRY_COUNT, localConductorConfig, networkedConductorConfig, awaitIntegration, delay } from './common'
import { installAgents } from './installAgents'
import { getTimestamp } from './utils'

module.exports = async (orchestrator) => {
orchestrator.registerScenario('transient nodes-local', async (s, t) => {
Expand All @@ -19,7 +18,7 @@ const gotChannelsAndMessages = async(t, name, happ, channelEntry, retry_count, r
while (true) {
const channel_list = await happ.call('chat', 'list_channels', { category: "General" });
console.log(`${name}'s channel list:`, channel_list.channels);
let batch_payload = { channel: channelEntry, active_chatter: false, earlier_than: getTimestamp(), target_message_count: 2 }
let batch_payload = { channel: channelEntry, active_chatter: false, target_message_count: 2 }

const r = await happ.call('chat', 'list_messages', batch_payload)
t.ok(r)
Expand Down
1 change: 0 additions & 1 deletion tests/src/utils.ts

This file was deleted.

2 changes: 1 addition & 1 deletion zomes/chat/src/entries/message/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ pub(crate) fn create_message(message_input: MessageInput) -> ChatResult<MessageD
let path_hash = path.hash()?;
let hp: &Vec<_> = path.as_ref();
let hour = String::try_from(&hp[hp.len() - 1])?;
debug!("COMMITING TO HOUR::: {:?}", hour);
debug!("committing message to hour {:?}", hour);
// Get the hash of the last_seen of this message
let parent_hash_entry = match last_seen {
LastSeen::Message(hash_entry) => hash_entry,
Expand Down

0 comments on commit f7c08f2

Please sign in to comment.