# Week 6 Hi everyone, this week I continued my work on my `is_better_update` [PR](https://github.com/prysmaticlabs/prysm/pull/14186) and added tests for the said helper function. This week I will also be submitting my project proposal to finalise the project formally even though I have been working on it for a while now. ## Overview As I said in my last week update, for each return statement in the helper function, there should be 2 tests. For example consider the following snippet from the function: ```go if newHasSupermajority != oldHasSupermajority { return newHasSupermajority } ``` One test would be for when `newHasSupermajority` is true and `oldHasSuperMajority` is false. Another would be for when `oldHasSupermajority` is true and `newHasSupermajority` is false. ### Setting up tests: ```go func TestIsBetterUpdate(t *testing.T) { testCases := []struct { name string oldUpdate *ethpbv2.LightClientUpdate newUpdate *ethpbv2.LightClientUpdate expectedResult bool }{ { name: "new has supermajority but old doesn't", oldUpdate: &ethpbv2.LightClientUpdate{}, newUpdate: &ethpbv2.LightClientUpdate{}, expectedResult: true }, } for _, testCase := range testCases { t.Run(testCase.name, func(t *testing.T) { assert.Equal(t, testCase.expectedResult, IsBetterUpdate(testCase.newUpdate, testCase.oldUpdate)) }) } } ``` Now for the return statement mentioned above, the tests would look like this: ```go func TestIsBetterUpdate(t *testing.T) { testCases := []struct { name string oldUpdate *ethpbv2.LightClientUpdate newUpdate *ethpbv2.LightClientUpdate expectedResult bool }{ { name: "new has supermajority but old doesn't", oldUpdate: &ethpbv2.LightClientUpdate{ SyncAggregate: &ethpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b01111100, 0b1}, // [0,0,1,1,1,1,1,0] }, }, newUpdate: &ethpbv2.LightClientUpdate{ SyncAggregate: &ethpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b11111100, 0b1}, // [0,0,1,1,1,1,1,1] }, }, expectedResult: true, }, { name: "old has supermajority but new doesn't", oldUpdate: &ethpbv2.LightClientUpdate{ SyncAggregate: &ethpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b11111100, 0b1}, // [0,0,1,1,1,1,1,1] }, }, newUpdate: &ethpbv2.LightClientUpdate{ SyncAggregate: &ethpbv1.SyncAggregate{ SyncCommitteeBits: []byte{0b01111100, 0b1}, // [0,0,1,1,1,1,1,0] }, }, expectedResult: false, }, (continued)... ``` With 8 return statements there are supposed to be 16 such tests in total. The rest can be found [here](https://github.com/prysmaticlabs/prysm/pull/14186/files#diff-48e770f3ce0719d102aafdb1b79b8f58c32a00d7388a8330208fd8ec0c20be5c) ## What next As of now, Radek is yet to review the PR. If any changes are requested I will be addressing them coming week, otherwise I will be moving forward with the next steps on the roadmap in the project proposal.