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

[BUG] There is no check if the network is wrong #16

Closed
mehrdadmms opened this issue Jun 24, 2024 · 0 comments
Closed

[BUG] There is no check if the network is wrong #16

mehrdadmms opened this issue Jun 24, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@mehrdadmms
Copy link

Case

based on the code below:

  public static getInstance(network: string): Ergo {
    const config = getErgoConfig(network);

    if (!Ergo._instances) {
      Ergo._instances = new LRUCache<string, Ergo>({
        max: config.network.maxLRUCacheInstances,
      });
    }

    if (!Ergo._instances.has(config.network.name)) {
      if (network) {
        Ergo._instances.set(config.network.name, new Ergo(network));
      } else {
        throw new Error(
          `Ergo.getInstance received an unexpected network: ${network}.`,
        );
      }
    }

    return Ergo._instances.get(config.network.name) as Ergo;
  }

when initializing a network if I enter an invalid network like “sadefcqwr,l” no error will be returned.

this is the code I write:

import { Ergo } from './ergo';
const ergo = new Ergo('sadefcqwr,l');
console.log(ergo);

and this is the output:

Ergo {
_assetMap: {},
_chain: 'ergo',
_ready: false,
ammPools: [],
_networkPrefix: 16,
_network: 'sadef cqwr,l',
_node: NodeService {
nodeURL: 'http://213.239.193.208:9053/',
timeout: 50000
},
other configs ...
}
@mehrdadmms mehrdadmms added the bug Something isn't working label Jun 24, 2024
@mehrdadmms mehrdadmms changed the title ❌ There is no check if the network is wrong [BUG] There is no check if the network is wrong Jun 24, 2024
hirotadashi added a commit that referenced this issue Jun 24, 2024
@mehrdadmms mehrdadmms assigned satiparpar and unassigned hirotadashi Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants