Skip to content

Commit

Permalink
feat: make EndKey updatable
Browse files Browse the repository at this point in the history
  • Loading branch information
shifty11 committed Apr 25, 2024
1 parent 49a095b commit 1abb38d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions x/pool/keeper/msg_server_update_pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ func (k msgServer) UpdatePool(goCtx context.Context, req *types.MsgUpdatePool) (
if update.CompressionId != nil {
pool.CurrentCompressionId = *update.CompressionId
}
if update.EndKey != nil {
pool.EndKey = *update.EndKey
}

k.SetPool(ctx, pool)

Expand Down
13 changes: 8 additions & 5 deletions x/pool/keeper/msg_server_update_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() {
msg := &types.MsgUpdatePool{
Authority: i.DUMMY[0],
Id: 0,
Payload: "{\"Name\":\"TestPool\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":\"100000000000\",\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}",
Payload: "{\"Name\":\"TestPool\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":\"100000000000\",\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1,\"EndKey\":\"1\"}",
}

// ACT
Expand All @@ -61,7 +61,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() {
msg := &types.MsgUpdatePool{
Authority: i.DUMMY[0],
Id: 0,
Payload: "{\"Name\":\"TestPool\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":\"100000000000\",\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}",
Payload: "{\"Name\":\"TestPool\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":\"100000000000\",\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1,\"EndKey\":\"1\"}",
}

proposal, _ := BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand All @@ -78,7 +78,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() {
msg := &types.MsgUpdatePool{
Authority: gov,
Id: 0,
Payload: "{\"Name\":\"TestPool\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}",
Payload: "{\"Name\":\"TestPool\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1,\"EndKey\":\"1\"}",
}

p, v := BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand Down Expand Up @@ -128,6 +128,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() {
},
CurrentStorageProviderId: 2,
CurrentCompressionId: 1,
EndKey: "1",
}))
})

Expand Down Expand Up @@ -186,6 +187,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() {
},
CurrentStorageProviderId: 0,
CurrentCompressionId: 0,
EndKey: "",
}))
})

Expand All @@ -197,7 +199,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() {
msg := &types.MsgUpdatePool{
Authority: gov,
Id: 1,
Payload: "{\"Name\":\"TestPool2\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}",
Payload: "{\"Name\":\"TestPool2\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1,\"EndKey\":\"1\"}",
}

p, v := BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand Down Expand Up @@ -246,6 +248,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() {
},
CurrentStorageProviderId: 2,
CurrentCompressionId: 1,
EndKey: "1",
}))
})

Expand All @@ -254,7 +257,7 @@ var _ = Describe("msg_server_update_pool.go", Ordered, func() {
msg := &types.MsgUpdatePool{
Authority: gov,
Id: 1,
Payload: "invalid_json_payload\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1}",
Payload: "invalid_json_payload\",\"Runtime\":\"@kyve/test\",\"Logo\":\"ar://Tewyv2P5VEG8EJ6AUQORdqNTectY9hlOrWPK8wwo-aU\",\"Config\":\"ar://DgdB-2hLrxjhyEEbCML__dgZN5_uS7T6Z5XDkaFh3P0\",\"StartKey\":\"0\",\"UploadInterval\":60,\"InflationShareWeight\":10000,\"MinDelegation\":100000000000,\"MaxBundleSize\":100,\"Version\":\"0.0.0\",\"Binaries\":\"{}\",\"StorageProviderId\":2,\"CompressionId\":1,\"EndKey\":\"1\"}",
}

p, _ := BuildGovernanceTxs(s, []sdk.Msg{msg})
Expand Down
1 change: 1 addition & 0 deletions x/pool/types/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ type PoolUpdate struct {
MaxBundleSize *uint64
StorageProviderId *uint32
CompressionId *uint32
EndKey *string
}

// ValidateBasic does a sanity check on the provided data.
Expand Down

0 comments on commit 1abb38d

Please sign in to comment.