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

fix: Fund11 eventdb params and test fix | NPG-000 #615

Merged
merged 12 commits into from
Nov 3, 2023
3 changes: 1 addition & 2 deletions .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
pull_request:
branches:
- main
- fix-earthly-integration-testing

permissions:
id-token: write
Expand Down Expand Up @@ -41,4 +40,4 @@ jobs:
env:
EARTHLY_SECRETS: "IDEASCALE_EMAIL=${{ secrets.IDEASCALE_EMAIL }}, IDEASCALE_PASSWORD=${{ secrets.IDEASCALE_PASSWORD }}, IDEASCALE_API_TOKEN=${{ secrets.IDEASCALE_API_TOKEN }}"
run: |
earthly -P --buildkit-host "tcp://${{ secrets.EARTHLY_SATELLITE_ADDRESS }}:8372" +test
earthly -P --buildkit-host "tcp://${{ secrets.EARTHLY_SATELLITE_ADDRESS }}:8372" +test-all
19 changes: 10 additions & 9 deletions Earthfile
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,16 @@ all:
END

# Build and tag all Docker images
BUILD ./containers/event-db-migrations+docker --tag=$tag --registry=$registry_final
BUILD ./containers/event-db-migrations+publish --tag=$tag --registry=$registry_final

# Build crate images from the workspace
BUILD ./src/jormungandr/jormungandr+docker --tag=$tag --registry=$registry_final
BUILD ./src/jormungandr/jcli+docker --tag=$tag --registry=$registry_final
BUILD ./src/catalyst-toolbox/catalyst-toolbox+docker --tag=$tag --registry=$registry_final
BUILD ./src/voting-tools-rs+docker --tag=$tag --registry=$registry_final
BUILD ./src/cat-data-service+docker --tag=$tag --registry=$registry_final
BUILD ./src/cat-data-service+publish --tag=$tag --registry=$registry_final

BUILD ./services/voting-node+docker --tag=$tag --registry=$registry_final
BUILD ./services/voting-node+publish --tag=$tag --registry=$registry_final
BUILD ./utilities/ideascale-importer+docker --tag=$tag --registry=$registry_final

all-with-tags:
Expand All @@ -123,9 +123,10 @@ ci:

# Define the test stage, which runs the Rust project's tests
test-all:
BUILD ./src/event-db+test
BUILD ./src/cat-data-service+test
BUILD ./utilities/ideascale-importer+test
# TODO: Enable this when CI supports passing -P dynamically
# BUILD ./src/event-db+test
# BUILD ./src/cat-data-service+test
# BUILD ./utilities/ideascale-importer+test

tag-workspace:
ARG SVU_VERSION=1.10.2
Expand All @@ -145,9 +146,9 @@ tag-workspace:

local:
LOCALLY
BUILD ./containers/event-db-migrations+docker
BUILD ./src/cat-data-service+docker
BUILD ./services/voting-node+docker
BUILD ./containers/event-db-migrations+publish
BUILD ./src/cat-data-service+publish
BUILD ./services/voting-node+publish

RUN mkdir -p ./local
COPY ./containers/dev-local+build/docker-compose.yml ./local/
48 changes: 29 additions & 19 deletions src/event-db/src/queries/event/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,8 @@ impl EventDB {
LEFT JOIN snapshot ON event.row_id = snapshot.event
WHERE event.row_id = $1;";

const EVENT_GOALS_QUERY: &'static str = "SELECT goal.idx, goal.name
FROM goal
const EVENT_GOALS_QUERY: &'static str = "SELECT goal.idx, goal.name
FROM goal
WHERE goal.event_id = $1;";
}

Expand Down Expand Up @@ -204,14 +204,6 @@ mod tests {
assert_eq!(
events,
vec![
EventSummary {
id: EventId(0),
name: "Test Fund".to_string(),
starts: Some(DateTime::<Utc>::from_utc(NaiveDateTime::default(), Utc)),
ends: Some(DateTime::<Utc>::from_utc(NaiveDateTime::default(), Utc)),
reg_checked: None,
is_final: true,
},
EventSummary {
id: EventId(1),
name: "Test Fund 1".to_string(),
Expand Down Expand Up @@ -325,14 +317,6 @@ mod tests {
assert_eq!(
events,
vec![
EventSummary {
id: EventId(0),
name: "Test Fund".to_string(),
starts: Some(DateTime::<Utc>::from_utc(NaiveDateTime::default(), Utc)),
ends: Some(DateTime::<Utc>::from_utc(NaiveDateTime::default(), Utc)),
reg_checked: None,
is_final: true,
},
EventSummary {
id: EventId(1),
name: "Test Fund 1".to_string(),
Expand All @@ -359,10 +343,36 @@ mod tests {
)),
is_final: true,
},
EventSummary {
id: EventId(2),
name: "Test Fund 2".to_string(),
starts: Some(DateTime::<Utc>::from_utc(
NaiveDateTime::new(
NaiveDate::from_ymd_opt(2021, 5, 1).unwrap(),
NaiveTime::from_hms_opt(12, 0, 0).unwrap()
),
Utc
)),
ends: Some(DateTime::<Utc>::from_utc(
NaiveDateTime::new(
NaiveDate::from_ymd_opt(2021, 6, 1).unwrap(),
NaiveTime::from_hms_opt(12, 0, 0).unwrap()
),
Utc
)),
reg_checked: Some(DateTime::<Utc>::from_utc(
NaiveDateTime::new(
NaiveDate::from_ymd_opt(2021, 3, 31).unwrap(),
NaiveTime::from_hms_opt(12, 0, 0).unwrap()
),
Utc
)),
is_final: true,
},
]
);

let events = event_db.get_events(Some(1), Some(1)).await.unwrap();
let events = event_db.get_events(Some(1), Some(0)).await.unwrap();
assert_eq!(
events,
vec![EventSummary {
Expand Down
32 changes: 4 additions & 28 deletions src/event-db/src/queries/search.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,10 @@ mod tests {
.search(search_query.clone(), false, None, None)
.await
.unwrap();
assert_eq!(query_result.total, 6);
assert_eq!(query_result.total, 5);
assert_eq!(
query_result.results,
Some(ValueResults::Events(vec![
EventSummary {
id: EventId(0),
name: "Test Fund".to_string(),
starts: Some(DateTime::<Utc>::from_utc(NaiveDateTime::default(), Utc)),
ends: Some(DateTime::<Utc>::from_utc(NaiveDateTime::default(), Utc)),
reg_checked: None,
is_final: true,
},
EventSummary {
id: EventId(1),
name: "Test Fund 1".to_string(),
Expand Down Expand Up @@ -416,7 +408,7 @@ mod tests {
.search(search_query, true, None, None)
.await
.unwrap();
assert_eq!(query_result.total, 6);
assert_eq!(query_result.total, 5);
assert_eq!(query_result.results, None);

let search_query = SearchQuery {
Expand All @@ -434,7 +426,7 @@ mod tests {
.search(search_query.clone(), false, None, None)
.await
.unwrap();
assert_eq!(query_result.total, 6);
assert_eq!(query_result.total, 5);
assert_eq!(
query_result.results,
Some(ValueResults::Events(vec![
Expand Down Expand Up @@ -544,14 +536,6 @@ mod tests {
)),
is_final: true,
},
EventSummary {
id: EventId(0),
name: "Test Fund".to_string(),
starts: Some(DateTime::<Utc>::from_utc(NaiveDateTime::default(), Utc)),
ends: Some(DateTime::<Utc>::from_utc(NaiveDateTime::default(), Utc)),
reg_checked: None,
is_final: true,
}
]))
);

Expand Down Expand Up @@ -598,7 +582,7 @@ mod tests {
.search(search_query.clone(), false, None, Some(2))
.await
.unwrap();
assert_eq!(query_result.total, 4);
assert_eq!(query_result.total, 3);
assert_eq!(
query_result.results,
Some(ValueResults::Events(vec![
Expand Down Expand Up @@ -680,14 +664,6 @@ mod tests {
)),
is_final: true,
},
EventSummary {
id: EventId(0),
name: "Test Fund".to_string(),
starts: Some(DateTime::<Utc>::from_utc(NaiveDateTime::default(), Utc)),
ends: Some(DateTime::<Utc>::from_utc(NaiveDateTime::default(), Utc)),
reg_checked: None,
is_final: true,
}
]))
);

Expand Down
24 changes: 12 additions & 12 deletions src/event-db/stage_data/dev/00001_fund11_event.sql
Original file line number Diff line number Diff line change
Expand Up @@ -29,21 +29,21 @@ INSERT INTO event (
11,
'Fund 11',
'Catalyst Testnet - Fund 11',
'2023-11-01 21:00:00', -- Registration Snapshot Time
'2023-11-01 22:00:00', -- Snapshot Start.
'2023-11-06 21:00:00', -- Registration Snapshot Time
'2023-11-07 22:00:00', -- Snapshot Start.
450000000, -- Voting Power Threshold
1, -- Max Voting Power PCT
NULL, -- Review Rewards
'2023-06-16 19:56:00', -- Start Time
'2023-09-18 00:00:00', -- End Time
'2023-06-22 00:00:00', -- Insight Sharing Start
'2023-06-22 00:00:00', -- Proposal Submission Start
'2023-06-22 00:00:00', -- Refine Proposals Start
'2023-07-13 00:00:00', -- Finalize Proposals Start
'2023-07-20 00:00:00', -- Proposal Assessment Start
'2023-08-10 00:00:00', -- Assessment QA Start
'2023-11-02 11:00:00', -- Voting Starts
'2023-11-07 11:00:00', -- Voting Ends
'2023-11-03 00:00:00', -- Start Time
'2023-11-19 00:00:00', -- End Time
'2023-11-04 00:00:00', -- Insight Sharing Start
'2023-11-04 00:00:00', -- Proposal Submission Start
'2023-11-04 00:00:00', -- Refine Proposals Start
'2023-11-04 00:00:00', -- Finalize Proposals Start
'2023-11-04 00:00:00', -- Proposal Assessment Start
'2023-11-04 00:00:00', -- Assessment QA Start
'2023-11-08 11:00:00', -- Voting Starts
'2023-11-10 11:00:00', -- Voting Ends
'2023-11-18 11:00:00', -- Tallying Ends
NULL, -- Block 0 Data
NULL, -- Block 0 Hash
Expand Down
Loading