make sure test ip for snodes are random

pull/1974/head
Audric Ackermann 4 years ago
parent 121f8927ed
commit 4d72f24fd5
No known key found for this signature in database
GPG Key ID: 999F434D76324AD4

@ -18,6 +18,7 @@ import AbortController from 'abort-controller';
import * as Data from '../../../../../ts/data/data';
import { pathFailureCount } from '../../../../session/onions/onionPath';
import { SeedNodeAPI } from '../../../../session/seed_node_api';
import { generateFakeSnodeWithEdKey } from '../../../test-utils/utils';
chai.use(chaiAsPromised as any);
chai.should();
@ -63,8 +64,6 @@ describe('OnionPathsErrors', () => {
fakeSwarmForAssociatedWith: Array<string>;
let oldOnionPaths: Array<Array<Data.Snode>>;
const fakeIP = '8.8.8.8';
let fakePortCurrent = 20000;
beforeEach(async () => {
guardPubkeys = TestUtils.generateFakePubKeys(3).map(n => n.key);
@ -72,26 +71,10 @@ describe('OnionPathsErrors', () => {
SNodeAPI.Onions.resetSnodeFailureCount();
guardNodesArray = guardPubkeys.map(ed25519 => {
fakePortCurrent++;
return {
ip: fakeIP,
port: fakePortCurrent,
pubkey_ed25519: ed25519,
pubkey_x25519: ed25519,
};
});
guardNodesArray = guardPubkeys.map(generateFakeSnodeWithEdKey);
guardSnode1 = guardNodesArray[0];
otherNodesArray = otherNodesPubkeys.map(ed25519 => {
fakePortCurrent++;
return {
ip: fakeIP,
port: fakePortCurrent,
pubkey_ed25519: ed25519,
pubkey_x25519: ed25519,
};
});
otherNodesArray = otherNodesPubkeys.map(generateFakeSnodeWithEdKey);
fakeSnodePool = [...guardNodesArray, ...otherNodesArray];

@ -37,7 +37,8 @@ export function generateFakePubKeys(amount: number): Array<PubKey> {
export function generateFakeSnode(): Snode {
return {
ip: '136.243.103.171',
// tslint:disable: insecure-random
ip: `136.243.${Math.random() * 255}.${Math.random() * 255}`,
port: 22116,
pubkey_x25519: generateFakePubKeyStr(),
pubkey_ed25519: generateFakePubKeyStr(),
@ -46,7 +47,7 @@ export function generateFakeSnode(): Snode {
export function generateFakeSnodeWithEdKey(ed25519Pubkey: string): Snode {
return {
ip: '136.243.103.171',
ip: `136.243.${Math.random() * 255}.${Math.random() * 255}`,
port: 22116,
pubkey_x25519: generateFakePubKeyStr(),
pubkey_ed25519: ed25519Pubkey,

Loading…
Cancel
Save