fix #1518 and #1573 - removed potentially offensive words, made username generation deterministic, updated unit tests

This commit is contained in:
Goran Jovic 2017-08-01 17:52:08 +03:00 committed by Roman Volosovskyi
parent 8e22ce9466
commit 1ca35db17c
16 changed files with 263 additions and 285 deletions

View File

@ -305,9 +305,10 @@
(dispatch [::clear-chat-loaded-callbacks chat-id])))))
(defn prepare-chat [{:contacts/keys [contacts]} chat-id chat]
(let [name (get-in contacts [chat-id :name])]
(let [name (get-in contacts [chat-id :name])
whisper-identity (get-in contacts [chat-id :whisper-identity])]
(merge {:chat-id chat-id
:name (or name (generate-gfy))
:name (or name (generate-gfy whisper-identity))
:color default-chat-color
:group-chat false
:is-active true

View File

@ -58,6 +58,7 @@
group-chat [:chat :group-id]
name [:chat :name]
color [:chat :color]
public-key [:chat :public-key]
members [:current-chat-contacts]]
(let [{:keys [status]} (if group-chat
{:photo-path nil
@ -70,7 +71,7 @@
:font :default
:number-of-lines 1}
(if (str/blank? name)
(generate-gfy)
(generate-gfy public-key)
(or (get-contact-translated chat-id :name name)
(label :t/chat-name)))]
(when (or status content)

View File

@ -67,6 +67,7 @@
chat-id [:chat :chat-id]
contacts [:chat :contacts]
public? [:chat :public?]
public-key [:chat :public-key]
show-actions? [:chat-ui-props :show-actions?]
accounts [:get :accounts]
contact [:get-in [:contacts/contacts @chat-id]]
@ -76,7 +77,7 @@
show-actions?
creating?))
(let [chat-name (if (str/blank? name)
(generate-gfy)
(generate-gfy public-key)
(or (get-contact-translated chat-id :name name)
(label :t/chat-name)))]
[text {:style st/chat-name-text

View File

@ -21,7 +21,7 @@
(if (pos? (count (:name contact)))
(get-contact-translated whisper-identity :name name)
;;TODO is this correct behaviour?
(generate-gfy))]
(generate-gfy whisper-identity))]
(when info
[text {:style st/info-text}
info])]]))

View File

@ -47,13 +47,14 @@
[view
[ci/chat-icon (:photo-path account) {:size 52}]]])
(defview name-input [placeholder]
(defview name-input []
[account [:get-current-account]
new-name [:get-in [:profile-edit :name]]]
(let [current-name (:name account)]
(let [current-name (:name account)
public-key (:public-key account)]
[view {:style st/name-input-wrapper}
[text-input
{:placeholder placeholder
{:placeholder (gfycat/generate-gfy public-key)
:style (st/name-input-text (s/valid? ::profile.db/name (or new-name current-name)))
:font :medium
:default-value (or new-name current-name)
@ -169,20 +170,19 @@
(i18n/label :t/switch-users)]]]])
(defn drawer []
(let [placeholder (gfycat/generate-gfy)]
(fn []
[touchable-without-feedback {:on-press #(dismiss-keyboard!)}
[view st/drawer
[view st/upper-container
[view st/profile-container
[profile-picture]
[name-input placeholder]
[status-input]
[options-btn]]
[current-network]]
[view
[unsigned-transactions]
[switch-account]]]])))
(fn []
[touchable-without-feedback {:on-press #(dismiss-keyboard!)}
[view st/drawer
[view st/upper-container
[view st/profile-container
[profile-picture]
[name-input]
[status-input]
[options-btn]]
[current-network]]
[view
[unsigned-transactions]
[switch-account]]]]))
(defn drawer-view [items]
[drawer-layout {:drawerWidth 300

View File

@ -44,7 +44,7 @@
{:keys [public private]} (protocol/new-keypair!)
account {:public-key public-key
:address address
:name (generate-gfy)
:name (generate-gfy public-key)
:status (rand-nth statuses/data)
:signed-up? true
:updates-public-key public

View File

@ -17,7 +17,7 @@
{:keys [public private]} (protocol/new-keypair!)
account {:public-key public-key
:address address
:name (generate-gfy)
:name (generate-gfy public-key)
:photo-path (identicon public-key)
:updates-public-key public
:updates-private-key private

View File

@ -97,11 +97,11 @@
nil
st/opts-btn]]))
(defn chat-list-item-name [name group-chat? public?]
(defn chat-list-item-name [name group-chat? public? public-key]
(let [private-group? (and group-chat? (not public?))
public-group? (and group-chat? public?)
chat-name (if (str/blank? name)
(generate-gfy)
(generate-gfy public-key)
(truncate-str name 30))]
[view st/name-view
(when public-group?
@ -119,17 +119,17 @@
(defn chat-list-item-inner-view [{:keys [chat-id name color online
group-chat contacts public?
unremovable?] :as chat}
public-key unremovable?] :as chat}
edit?]
(let [last-message (subscribe [:get-last-message chat-id])
name (or (get-contact-translated chat-id :name name)
(generate-gfy))]
(generate-gfy public-key))]
[view st/chat-container
[view st/chat-icon-container
[chat-icon-view-chat-list chat-id group-chat name color online]]
[view st/chat-info-container
[view st/item-upper-container
[chat-list-item-name name group-chat public?]
[chat-list-item-name name group-chat public? public-key]
(when (and (not edit?) @last-message)
[view st/message-status-container
[message-status chat @last-message]

View File

@ -144,7 +144,7 @@
(fn [{:keys [contacts]}]
(if (> (count contacts) 0)
(let [{:keys [whisper-identity]} (first contacts)
contact {:name (generate-gfy)
contact {:name (generate-gfy whisper-identity)
:address id
:photo-path (identicon whisper-identity)
:whisper-identity whisper-identity}]
@ -441,6 +441,6 @@
{::request-contacts-by-address id}
{:dispatch (if (get-in db [:contacts/contacts id])
[:add-pending-contact id]
[:add-new-contact-and-open-chat {:name (generate-gfy)
[:add-new-contact-and-open-chat {:name (generate-gfy id)
:photo-path (identicon id)
:whisper-identity id}])})))

View File

@ -1,9 +1,13 @@
(ns status-im.utils.gfycat.adjectives)
;Names are only deterministic as long as word lists do not change!
;If you change this list, please also update the tests at:
;
; - cljs/status_im/test/utils/gfycat/core.cljs
(def data
["abandoned"
"able"
["able"
"absolute"
"academic"
"acceptable"
@ -17,14 +21,13 @@
"adventurous"
"babyish"
"back"
"bad"
"baggy"
"bare"
"barren"
"basic"
"beautiful"
"belated"
"beloved"
"bitter"
"calculating"
"calm"
"candid"
@ -38,7 +41,6 @@
"cavernous"
"celebrated"
"charming"
"damaged"
"damp"
"dangerous"
"dapper"
@ -46,7 +48,6 @@
"dark"
"darling"
"dazzling"
"dead"
"deadly"
"deafening"
"dear"
@ -60,12 +61,12 @@
"ecstatic"
"edible"
"educated"
"elderly"
"fabulous"
"failing"
"faint"
"fair"
"faithful"
"fake"
"familiar"
"famous"
"fancy"
@ -96,42 +97,31 @@
"ideal"
"idealistic"
"identical"
"idiotic"
"idle"
"idolized"
"ignorant"
"ill"
"illegal"
"jaded"
"jagged"
"jampacked"
"kaleidoscopic"
"keen"
"lame"
"lanky"
"large"
"last"
"lasting"
"late"
"lavish"
"lawful"
"mad"
"madeup"
"magnificent"
"majestic"
"major"
"male"
"mammoth"
"married"
"marvelous"
"married"
"naive"
"narrow"
"nasty"
"natural"
"naughty"
"obedient"
"obese"
"oblong"
"oblong"
"obvious"
"occasional"
@ -160,7 +150,6 @@
"recent"
"reckless"
"rectangular"
"sad"
"safe"
"salty"
"same"
@ -171,7 +160,6 @@
"satisfied"
"scaly"
"scarce"
"scared"
"scary"
"scented"
"scholarly"
@ -181,12 +169,11 @@
"scrawny"
"second"
"secondary"
"secondhand"
"secret"
"selfassured"
"selfish"
"selfreliant"
"sentimental"
"single"
"talkative"
"tall"
"tame"
@ -198,11 +185,8 @@
"taut"
"tedious"
"teeming"
"ugly"
"ultimate"
"unacceptable"
"unaware"
"uncomfortable"
"uncommon"
"unconscious"
"understated"
@ -222,10 +206,11 @@
"waterlogged"
"watery"
"wavy"
"weak"
"weird"
"yawning"
"yearly"
"zany"
"false"
"active"
"actual"
"adept"
@ -247,9 +232,6 @@
"bighearted"
"biodegradable"
"bitesized"
"bitter"
"black"
"cheap"
"cheerful"
"cheery"
"chief"
@ -279,24 +261,17 @@
"elaborate"
"elastic"
"elated"
"elderly"
"electric"
"elegant"
"elementary"
"elliptical"
"embarrassed"
"fast"
"fat"
"fatal"
"fatherly"
"favorable"
"favorite"
"fearful"
"fearless"
"feisty"
"feline"
"female"
"feminine"
"few"
"fickle"
"gifted"
@ -308,17 +283,14 @@
"gleeful"
"glistening"
"glittering"
"gross"
"hardtofind"
"harmful"
"harmless"
"harmonious"
"harsh"
"hasty"
"hateful"
"haunting"
"illfated"
"illinformed"
"illiterate"
"illustrious"
"imaginary"
"imaginative"
@ -332,7 +304,6 @@
"jittery"
"key"
"kind"
"lazy"
"leading"
"leafy"
"lean"
@ -340,7 +311,6 @@
"legal"
"legitimate"
"light"
"masculine"
"massive"
"mature"
"meager"
@ -358,7 +328,6 @@
"odd"
"oddball"
"offbeat"
"offensive"
"official"
"old"
"periodic"
@ -368,7 +337,6 @@
"pesky"
"pessimistic"
"petty"
"phony"
"physical"
"piercing"
"pink"
@ -394,8 +362,6 @@
"shadowy"
"shady"
"shallow"
"shameful"
"shameless"
"sharp"
"shimmering"
"shiny"
@ -407,35 +373,28 @@
"showy"
"shrill"
"shy"
"sick"
"silent"
"silky"
"tempting"
"tender"
"tense"
"tepid"
"terrible"
"terrific"
"testy"
"thankful"
"that"
"these"
"tremendous"
"uneven"
"unfinished"
"unfit"
"unfolded"
"unfortunate"
"unhappy"
"unhealthy"
"uniform"
"unimportant"
"unique"
"valuable"
"vapid"
"variable"
"vast"
"velvety"
"weak"
"wealthy"
"weary"
"webbed"
@ -443,7 +402,6 @@
"weekly"
"weepy"
"weighty"
"weird"
"welcome"
"welldocumented"
"yellow"
@ -461,7 +419,6 @@
"alive"
"all"
"altruistic"
"blackandwhite"
"bland"
"blank"
"blaring"
@ -486,7 +443,6 @@
"competent"
"complete"
"delightful"
"delirious"
"demanding"
"dense"
"dental"
@ -507,7 +463,6 @@
"energetic"
"enlightened"
"enormous"
"filthy"
"fine"
"finished"
"firm"
@ -519,7 +474,6 @@
"flamboyant"
"flashy"
"flat"
"flawed"
"flawless"
"flickering"
"gloomy"
@ -538,13 +492,11 @@
"heavy"
"hefty"
"helpful"
"helpless"
"humongous"
"impartial"
"impeccable"
"imperfect"
"imperturbable"
"impish"
"impolite"
"important"
"impossible"
"impractical"
@ -554,6 +506,7 @@
"joint"
"jolly"
"jovial"
"juvenile"
"kindhearted"
"kindly"
"lighthearted"
@ -601,6 +554,7 @@
"polished"
"polite"
"political"
"pungent"
"queasy"
"querulous"
"reliable"
@ -617,8 +571,6 @@
"similar"
"simple"
"simplistic"
"sinful"
"single"
"sizzling"
"skeletal"
"skinny"
@ -652,11 +604,8 @@
"united"
"unkempt"
"unknown"
"unlawful"
"unlined"
"unlucky"
"unnatural"
"unpleasant"
"unrealistic"
"venerated"
"vengeful"
@ -675,6 +624,8 @@
"whimsical"
"whirlwind"
"whispered"
"worse"
"writhing"
"yellowish"
"zesty"
"amazing"
@ -722,13 +673,7 @@
"dimpled"
"dimwitted"
"direct"
"disastrous"
"discrete"
"disfigured"
"disgusting"
"disloyal"
"dismal"
"enraged"
"entire"
"envious"
"equal"
@ -762,14 +707,12 @@
"greedy"
"green"
"hidden"
"hideous"
"high"
"highlevel"
"hilarious"
"hoarse"
"hollow"
"homely"
"impure"
"inborn"
"incomparable"
"incompatible"
@ -790,17 +733,13 @@
"live"
"lively"
"livid"
"loathsome"
"lone"
"lonely"
"long"
"milky"
"mindless"
"miniature"
"minor"
"minty"
"miserable"
"miserly"
"misguided"
"misty"
"mixed"
@ -830,7 +769,6 @@
"prestigious"
"questionable"
"quick"
"repulsive"
"revolving"
"rewarding"
"rich"
@ -889,7 +827,6 @@
"vigorous"
"villainous"
"violet"
"white"
"whole"
"whopping"
"wicked"
@ -912,7 +849,6 @@
"arid"
"aromatic"
"artistic"
"ashamed"
"assured"
"astonishing"
"athletic"
@ -937,12 +873,9 @@
"creamy"
"creative"
"creepy"
"criminal"
"crisp"
"dirty"
"disguised"
"dishonest"
"dismal"
"distant"
"distant"
"distinct"
@ -974,21 +907,17 @@
"friendly"
"frightened"
"frightening"
"frigid"
"gregarious"
"grim"
"grimy"
"gripping"
"grizzled"
"gross"
"grotesque"
"grouchy"
"grounded"
"honest"
"honorable"
"honored"
"hopeful"
"horrible"
"hospitable"
"hot"
"huge"
@ -998,7 +927,6 @@
"informal"
"innocent"
"insecure"
"insidious"
"insignificant"
"insistent"
"instructive"
@ -1020,12 +948,10 @@
"modern"
"modest"
"moist"
"monstrous"
"monthly"
"monumental"
"moral"
"mortified"
"motherly"
"motionless"
"nocturnal"
"noisy"
@ -1081,7 +1007,6 @@
"stimulating"
"stingy"
"stormy"
"straight"
"strange"
"strict"
"strident"
@ -1093,10 +1018,8 @@
"tough"
"tragic"
"trained"
"traumatic"
"treasured"
"tremendous"
"tremendous"
"triangular"
"tricky"
"trifling"
@ -1110,7 +1033,6 @@
"unwitting"
"unwritten"
"upbeat"
"violent"
"virtual"
"virtuous"
"visible"
@ -1153,7 +1075,6 @@
"critical"
"crooked"
"crowded"
"cruel"
"crushing"
"cuddly"
"cultivated"
@ -1169,11 +1090,8 @@
"drab"
"drafty"
"dramatic"
"dreary"
"droopy"
"dry"
"dual"
"dull"
"dutiful"
"excited"
"exciting"
@ -1203,17 +1121,13 @@
"growling"
"grown"
"grubby"
"gruesome"
"grumpy"
"guilty"
"gullible"
"gummy"
"humble"
"humiliating"
"humming"
"humongous"
"hungry"
"hurtful"
"husky"
"intelligent"
"intent"
@ -1224,14 +1138,11 @@
"intrepid"
"ironclad"
"irresponsible"
"irritating"
"itchy"
"jumpy"
"junior"
"juvenile"
"known"
"kooky"
"kosher"
"low"
"loyal"
"lucky"
@ -1243,12 +1154,10 @@
"mountainous"
"muddy"
"muffled"
"multicolored"
"mundane"
"murky"
"mushy"
"musty"
"muted"
"mysterious"
"noteworthy"
"novel"
@ -1256,7 +1165,6 @@
"numb"
"nutritious"
"nutty"
"onerlooked"
"outrageous"
"outstanding"
"oval"
@ -1268,12 +1176,10 @@
"proud"
"prudent"
"punctual"
"pungent"
"puny"
"pure"
"purple"
"pushy"
"putrid"
"puzzled"
"puzzling"
"quirky"
@ -1282,17 +1188,14 @@
"royal"
"rubbery"
"ruddy"
"rude"
"rundown"
"runny"
"rural"
"rusty"
"stupendous"
"stupid"
"sturdy"
"stylish"
"subdued"
"submissive"
"substantial"
"subtle"
"suburban"
@ -1335,28 +1238,19 @@
"vivacious"
"vivid"
"voluminous"
"worried"
"worrisome"
"worse"
"worst"
"worthless"
"worthwhile"
"worthy"
"wrathful"
"wretched"
"writhing"
"wrong"
"wry"
"yummy"
"true"
"aliceblue"
"antiquewhite"
"aqua"
"aquamarine"
"azure"
"beige"
"bisque"
"black"
"blanchedalmond"
"blue"
"blueviolet"
@ -1499,7 +1393,6 @@
"violet"
"violetred"
"wheat"
"white"
"whitesmoke"
"yellow"
"yellowgreen"])

View File

@ -1,5 +1,11 @@
(ns status-im.utils.gfycat.animals)
;Names are only deterministic as long as word lists do not change!
;If you change this list, please also update the tests at:
;
; - cljs/status_im/test/utils/gfycat/core.cljs
(def data
["aardvark"
"aardwolf"
@ -20,36 +26,36 @@
"adouri"
"aegeancat"
"affenpinscher"
"afghanhound"
"africanaugurbuzzard"
"africanbushviper"
"africancivet"
"africanclawedfrog"
"africanelephant"
"africanfisheagle"
"africangoldencat"
"africangroundhornbill"
"africanharrierhawk"
"africanhornbill"
"africanjacana"
"africanmolesnake"
"africanparadiseflycatcher"
"africanpiedkingfisher"
"africanporcupine"
"africanrockpython"
"africanwildcat"
"africanwilddog"
"hound"
"augurbuzzard"
"bushviper"
"civet"
"clawedfrog"
"elephant"
"fisheagle"
"goldencat"
"groundhornbill"
"harrierhawk"
"hornbill"
"jacana"
"molesnake"
"paradiseflycatcher"
"piedkingfisher"
"porcupine"
"rockpython"
"wildcat"
"wilddog"
"agama"
"agouti"
"aidi"
"airedale"
"airedaleterrier"
"akitainu"
"alabamamapturtle"
"alaskajingle"
"alaskanhusky"
"alaskankleekai"
"alaskanmalamute"
"mapturtle"
"jingle"
"husky"
"kleekai"
"malamute"
"albacoretuna"
"albatross"
"albertosaurus"
@ -70,36 +76,36 @@
"amazontreeboa"
"amberpenshell"
"ambushbug"
"americanalligator"
"americanavocet"
"americanbadger"
"americanbittern"
"americanblackvulture"
"americanbobtail"
"americanbulldog"
"americancicada"
"americancrayfish"
"americancreamdraft"
"americancrocodile"
"americancrow"
"americancurl"
"americangoldfinch"
"americanindianhorse"
"americankestrel"
"americanlobster"
"americanmarten"
"americanpainthorse"
"americanquarterhorse"
"americanratsnake"
"americanredsquirrel"
"americanriverotter"
"americanrobin"
"americansaddlebred"
"americanshorthair"
"americantoad"
"americanwarmblood"
"americanwigeon"
"americanwirehair"
"alligator"
"avocet"
"badger"
"bittern"
"vulture"
"bobtail"
"bulldog"
"cicada"
"crayfish"
"creamdraft"
"crocodile"
"crow"
"curl"
"goldfinch"
"indianhorse"
"kestrel"
"lobster"
"marten"
"painthorse"
"quarterhorse"
"ratsnake"
"redsquirrel"
"riverotter"
"robin"
"saddlebred"
"shorthair"
"toad"
"warmblood"
"wigeon"
"wirehair"
"amethystgemclam"
"amethystinepython"
"amethystsunbird"
@ -114,7 +120,6 @@
"anchovy"
"andalusianhorse"
"andeancat"
"andeancockoftherock"
"andeancondor"
"anemone"
"anemonecrab"
@ -181,21 +186,19 @@
"arrowworm"
"arthropods"
"aruanas"
"asianconstablebutterfly"
"asiandamselfly"
"asianelephant"
"asianlion"
"asianpiedstarling"
"asianporcupine"
"asiansmallclawedotter"
"asiantrumpetfish"
"asianwaterbuffalo"
"asiaticgreaterfreshwaterclam"
"asiaticlesserfreshwaterclam"
"asiaticmouflon"
"asiaticwildass"
"constablebutterfly"
"damselfly"
"elephant"
"lion"
"piedstarling"
"porcupine"
"smallclawedotter"
"trumpetfish"
"waterbuffalo"
"greaterfreshwaterclam"
"lesserfreshwaterclam"
"mouflon"
"asp"
"ass"
"assassinbug"
"astarte"
"astrangiacoral"
@ -282,17 +285,14 @@
"bighornsheep"
"bigmouthbass"
"bilby"
"billygoat"
"binturong"
"bird"
"birdofparadise"
"bison"
"bittern"
"blackandtancoonhound"
"blackbear"
"blackbird"
"blackbuck"
"blackcrappie"
"blackfish"
"blackfly"
"blackfootedferret"
@ -311,12 +311,10 @@
"bluebird"
"bluebottle"
"bluebottlejellyfish"
"bluebreastedkookaburra"
"bluefintuna"
"bluefish"
"bluegill"
"bluejay"
"bluemorphobutterfly"
"blueshark"
"bluet"
"bluetickcoonhound"
@ -427,11 +425,7 @@
"coati"
"cob"
"cobra"
"cock"
"cockatiel"
"cockatoo"
"cockerspaniel"
"cockroach"
"cod"
"coelacanth"
"collardlizard"
@ -457,7 +451,6 @@
"corydorascatfish"
"cottonmouth"
"cottontail"
"cougar"
"cow"
"cowbird"
"cowrie"
@ -486,8 +479,6 @@
"cutworm"
"cygnet"
"dachshund"
"daddylonglegs"
"dairycow"
"dalmatian"
"damselfly"
"danishswedishfarmdog"
@ -520,8 +511,6 @@
"doe"
"dog"
"dogfish"
"dogwoodclubgall"
"dogwoodtwigborer"
"dolphin"
"donkey"
"dorado"
@ -529,7 +518,6 @@
"dorking"
"dormouse"
"dotterel"
"douglasfirbarkbeetle"
"dove"
"dowitcher"
"drafthorse"
@ -546,22 +534,15 @@
"duckling"
"dugong"
"duiker"
"dungbeetle"
"dungenesscrab"
"dunlin"
"dunnart"
"dutchshepherddog"
"dutchsmoushond"
"dwarfmongoose"
"dwarfrabbit"
"eagle"
"earthworm"
"earwig"
"easternglasslizard"
"easternnewt"
"easteuropeanshepherd"
"eastrussiancoursinghounds"
"eastsiberianlaika"
"echidna"
"eel"
"eelelephant"
@ -761,7 +742,6 @@
"guineapig"
"gull"
"guppy"
"gypsymoth"
"gyrfalcon"
"hackee"
"haddock"
@ -807,7 +787,6 @@
"hermitcrab"
"heron"
"herring"
"heterodontosaurus"
"hind"
"hippopotamus"
"hoatzin"
@ -1013,7 +992,6 @@
"leopardseal"
"leveret"
"lhasaapso"
"lice"
"liger"
"lightningbug"
"limpet"
@ -1040,12 +1018,9 @@
"lunamoth"
"lungfish"
"lynx"
"lynxÂ"
"macaque"
"macaw"
"macropod"
"madagascarhissingroach"
"maggot"
"magpie"
"maiasaura"
"majungatholus"
@ -1084,13 +1059,11 @@
"mealworm"
"meerkat"
"megalosaurus"
"megalotomusquinquespinosus"
"megaraptor"
"merganser"
"merlin"
"metalmarkbutterfly"
"metamorphosis"
"mice"
"microvenator"
"midge"
"milksnake"
@ -1108,9 +1081,8 @@
"molly"
"monarch"
"mongoose"
"mongrel"
"monkey"
"monkfishÂ"
"monkfish"
"monoclonius"
"montanoceratops"
"moorhen"
@ -1126,7 +1098,6 @@
"mountaincat"
"mountainlion"
"mouse"
"mouse/mice"
"mousebird"
"mudpuppy"
"mule"
@ -1141,12 +1112,11 @@
"mutt"
"myna"
"mynah"
"myotisÂ"
"myotis"
"nabarlek"
"nag"
"naga"
"nagapies"
"nakedmolerat"
"nandine"
"nandoo"
"nandu"
@ -1175,9 +1145,8 @@
"nightheron"
"nightingale"
"nightjar"
"nijssenissdwarfchihlid"
"nilgai"
"ninebandedarmadillo"
"armadillo"
"noctilio"
"noctule"
"noddy"
@ -1186,7 +1155,6 @@
"northernelephantseal"
"northernflyingsquirrel"
"northernfurseal"
"northernhairynosedwombat"
"northernpike"
"northernseahorse"
"northernspottedowl"
@ -1200,7 +1168,6 @@
"nuthatch"
"nutria"
"nyala"
"nymph"
"ocelot"
"octopus"
"okapi"
@ -1226,7 +1193,7 @@
"oxpecker"
"oyster"
"ozarkbigearedbat"
"pacaÂ"
"paca"
"pachyderm"
"pacificparrotlet"
"paddlefish"
@ -1254,12 +1221,11 @@
"pheasant"
"phoebe"
"phoenix"
"pig"
"pigeon"
"piglet"
"pika"
"pike"
"pikeperchÂ"
"pikeperch"
"pilchard"
"pinemarten"
"pinkriverdolphin"
@ -1277,7 +1243,6 @@
"plover"
"polarbear"
"polecat"
"polliwog"
"polyp"
"polyturator"
"pomeranian"
@ -1309,7 +1274,6 @@
"pupfish"
"puppy"
"purplemarten"
"pussycat"
"pygmy"
"python"
"quadrisectus"
@ -1381,7 +1345,7 @@
"rottweiler"
"sable"
"sableantelope"
"sablefishÂ"
"sablefish"
"saiga"
"sakimonkey"
"salamander"
@ -1442,10 +1406,8 @@
"silversidefish"
"siskin"
"skimmer"
"skink"
"skipper"
"skua"
"skunk"
"skylark"
"sloth"
"slothbear"
@ -1560,7 +1522,7 @@
"titmouse"
"toad"
"toadfish"
"tomtitÂ"
"tomtit"
"topi"
"tortoise"
"toucan"
@ -1676,7 +1638,6 @@
"wombat"
"woodborer"
"woodchuck"
"woodcock"
"woodnymphbutterfly"
"woodpecker"
"woodstorks"
@ -1700,7 +1661,6 @@
"xenopterygii"
"xenopus"
"xenotarsosaurus"
"xenurine"
"xenurusunicinctus"
"xerus"
"xiaosaurus"

View File

@ -1,15 +1,19 @@
(ns status-im.utils.gfycat.core
(:require [status-im.utils.gfycat.animals :as animals]
[status-im.utils.gfycat.adjectives :as adjectives]
[clojure.string :as str]))
[clojure.string :as str]
[status-im.utils.random :as rnd]
[status-im.utils.datetime :refer [now-ms]]))
(defn- pick-random
[vector]
(str/capitalize (rand-nth vector)))
[gen vector]
(str/capitalize (rnd/seeded-rand-nth gen vector)))
(defn generate-gfy
[]
(let [first-adjective (pick-random adjectives/data)
second-adjective (pick-random adjectives/data)
animal (pick-random animals/data)]
([public-key]
(let [gen (rnd/rand-gen public-key)
first-adjective (pick-random gen adjectives/data)
second-adjective (pick-random gen adjectives/data)
animal (pick-random gen animals/data)]
(str first-adjective " " second-adjective " " animal)))
([] (generate-gfy (now-ms))))

View File

@ -8,3 +8,14 @@
(defn id []
(str (timestamp) "-" (.guid chance)))
(defn rand-gen
[seed]
(dependencies/Chance. seed))
(defn seeded-rand-int
[gen n] (.integer gen #js {:min 0 :max (dec n)}))
(defn seeded-rand-nth
[gen coll]
(nth coll (seeded-rand-int gen (count coll))))

View File

@ -7,7 +7,9 @@
[status-im.test.utils.utils]
[status-im.test.utils.money]
[status-im.test.utils.clocks]
[status-im.test.utils.erc20]))
[status-im.test.utils.erc20]
[status-im.test.utils.random]
[status-im.test.utils.gfycat.core]))
(enable-console-print!)
@ -24,4 +26,6 @@
'status-im.test.utils.utils
'status-im.test.utils.money
'status-im.test.utils.clocks
'status-im.test.utils.erc20)
'status-im.test.utils.erc20
'status-im.test.utils.random
'status-im.test.utils.gfycat.core)

View File

@ -0,0 +1,12 @@
(ns status-im.test.utils.gfycat.core
(:require [cljs.test :refer-macros [deftest is]]
[status-im.utils.gfycat.core :as gfy]))
(def message "Names are only deterministic as long as word lists do not change!\nIf you change the lists, please change the tests as well.")
(deftest test-generate-gfy
(is (= (gfy/generate-gfy "57348975ff9199ca636207a396b915d6b6a675b4") "Winged Fitting Mosquito") message)
(is (= (gfy/generate-gfy "e63d083d2d7a13a14632983b5820529445ca8109") "Mediumvioletred Melodic Waterdogs") message)
(is (= (gfy/generate-gfy "57348975ff9199ca636207a396b915d6b6a675b4") "Winged Fitting Mosquito") message)
(is (= (gfy/generate-gfy "26cf649aebb252a75aebc588e0d9ce93789dbe0b") "Educated Upright Arcticseal") message)
(is (= (gfy/generate-gfy "e63d083d2d7a13a14632983b5820529445ca8109") "Mediumvioletred Melodic Waterdogs") message))

View File

@ -0,0 +1,91 @@
(ns status-im.test.utils.random
(:require [cljs.test :refer-macros [deftest is]]
[status-im.utils.random :as random]))
(deftest test-seeded-rand-int
;try with one seed
(let [seed 0
gen (random/rand-gen seed)]
(is (= (random/seeded-rand-int gen 100) 54))
(is (= (random/seeded-rand-int gen 100) 59))
(is (= (random/seeded-rand-int gen 10) 7))
(is (= (random/seeded-rand-int gen 10) 8)))
;repeat with the same seed, but generator re-set
(let [seed 0
gen (random/rand-gen seed)]
(is (= (random/seeded-rand-int gen 100) 54))
(is (= (random/seeded-rand-int gen 100) 59))
(is (= (random/seeded-rand-int gen 10) 7))
(is (= (random/seeded-rand-int gen 10) 8)))
;a string seed
(let [seed "6ec565f4fec866a54761524f603cf037e20c2bfa"
gen (random/rand-gen seed)]
(is (= (random/seeded-rand-int gen 100) 7))
(is (= (random/seeded-rand-int gen 100) 4))
(is (= (random/seeded-rand-int gen 10) 5))
(is (= (random/seeded-rand-int gen 10) 7)))
;a string seed again
(let [seed "6ec565f4fec866a54761524f603cf037e20c2bfa"
gen (random/rand-gen seed)]
(is (= (random/seeded-rand-int gen 100) 7))
(is (= (random/seeded-rand-int gen 100) 4))
(is (= (random/seeded-rand-int gen 10) 5))
(is (= (random/seeded-rand-int gen 10) 7)))
;nil seed is the same as 0
(let [seed 0
gen (random/rand-gen seed)]
(is (= (random/seeded-rand-int gen 100) 54))
(is (= (random/seeded-rand-int gen 100) 59))
(is (= (random/seeded-rand-int gen 10) 7))
(is (= (random/seeded-rand-int gen 10) 8))))
(deftest test-seeded-rand-int-boundaries
(let [seed "6ec565f4fec866a54761524f603cf037e20c2bfa"
n 10
gen (random/rand-gen seed)
sample (into #{} (repeatedly 1000 #(random/seeded-rand-int gen n)))]
;no result should be negative
(is (empty? (filter #(< % 0) sample)))
;no result should be larger than n
(is (empty? (filter #(>= % n) sample)))
;and while there is a very small probability
;it is very unlikely and probably wrong if all 1000 calls
;got us the same number.
(is (> (count sample) 1))))
(deftest test-seeded-rand-nth
(let [seed "6ec565f4fec866a54761524f603cf037e20c2bfa"
gen (random/rand-gen seed)
coll [:a :b :c :d :e :f :g]]
(is (= (random/seeded-rand-nth gen coll) :a))
(is (= (random/seeded-rand-nth gen coll) :a))
(is (= (random/seeded-rand-nth gen coll) :e))
(is (= (random/seeded-rand-nth gen coll) :f))
(is (= (random/seeded-rand-nth gen coll) :c)))
;try again with the same seed but gen reset
(let [seed "6ec565f4fec866a54761524f603cf037e20c2bfa"
gen (random/rand-gen seed)
coll [:a :b :c :d :e :f :g]]
(is (= (random/seeded-rand-nth gen coll) :a))
(is (= (random/seeded-rand-nth gen coll) :a))
(is (= (random/seeded-rand-nth gen coll) :e))
(is (= (random/seeded-rand-nth gen coll) :f))
(is (= (random/seeded-rand-nth gen coll) :c)))
;try again with a different seed
(let [seed "57348975ff9199ca636207a396b915d6b6a675b4"
gen (random/rand-gen seed)
coll [:a :b :c :d :e :f :g]]
(is (= (random/seeded-rand-nth gen coll) :f))
(is (= (random/seeded-rand-nth gen coll) :c))
(is (= (random/seeded-rand-nth gen coll) :e))
(is (= (random/seeded-rand-nth gen coll) :e))
(is (= (random/seeded-rand-nth gen coll) :a)))
;and re-set
(let [seed "57348975ff9199ca636207a396b915d6b6a675b4"
gen (random/rand-gen seed)
coll [:a :b :c :d :e :f :g]]
(is (= (random/seeded-rand-nth gen coll) :f))
(is (= (random/seeded-rand-nth gen coll) :c))
(is (= (random/seeded-rand-nth gen coll) :e))
(is (= (random/seeded-rand-nth gen coll) :e))
(is (= (random/seeded-rand-nth gen coll) :a))))