Using global variables make testing hard, especially for the consensus module.
This becomes more apparent when you think about how to test GallocyState, GallocyServer, GallocyClient, and GallocyConfig together. Today, all of these major entities are global variables that are defined in entrypoint.h. Everything accesses these entities through these global handles, which makes unit testing hard.
This will require rethinking a few abstractions, since everything accesses these entities through the global handles. E.g., we'll need to rethink how we do HTTP callbacks in the consensus module because they depend on the ability to "change the state of the machine" based on HTTP responses, whereas the HTTP client only allows for a generic callback. This type of pattern is used in a few places, and each one will require a rethink.
Using global variables make testing hard, especially for the consensus module.
This becomes more apparent when you think about how to test
GallocyState
,GallocyServer
,GallocyClient
, andGallocyConfig
together. Today, all of these major entities are global variables that are defined inentrypoint.h
. Everything accesses these entities through these global handles, which makes unit testing hard.This will require rethinking a few abstractions, since everything accesses these entities through the global handles. E.g., we'll need to rethink how we do HTTP callbacks in the consensus module because they depend on the ability to "change the state of the machine" based on HTTP responses, whereas the HTTP client only allows for a generic callback. This type of pattern is used in a few places, and each one will require a rethink.