자바스크립트 is not defined 오류
-
게시물 수정 , 삭제는 로그인 필요
영상 강의를 보며 dapp 투표 프로그램을 따라 만드는 중인데요, 여기 25-37번째 줄의 accounts[0]에 access 하고자 하는데 왜 accounts가 정의되지 않았다고 오류 메시지가 뜨는지 잘 모르겠습니다. 위의 candidate같은 경우는 candidate[0]에 접근이 가능했었는데 왜 비슷한 맥락으로 보이는 저 부분은 왜 ReferenceError: accounts is not defined라고 나오는 것인가요...? 도움 주시면 감사하겠습니다. 하단은 작성하였던 코드와 오류 메시지입니다.
var Election = artifacts.require("./Election.sol");
contract("Election", function(accounts){
var electionInstance;
it("initializes with two candidates", function() {
return Election.deployed().then(function(instance) {
return instance.candidatesCount();
}).then(function(count) {
assert.equal(count, 2);
});
});
});
it("it initializes the candidates with the correct values", function() {
return Election.deployed().then(function(instance) {
electionInstance = instance;
return electionInstance.candidates(1);
}).then(function(candidate) {
assert.equal(candidate[0], 1, "contains the correct id");
assert.equal(candidate[1], "Candidate 1", "contains the correct name");
assert.equal(candidate[2], 0, "contains the correct votes count");
return electionInstance.candidates(2);
}).then(function(candidate) {
assert.equal(candidate[0], 2, "contains the correct id");
assert.equal(candidate[1], "Candidate 2", "contains the correct name");
assert.equal(candidate[2], 0, "contains the correct votes count");
});
});
it("allows a voter to cast a vote", function() {
return Election.deployed().then(function(instance) {
electionInstance = instance;
candidateId = 1;
return electionInstance.vote(candidateId, { from: accounts[0] });
}).then(function(receipt) {
return electionInstance.voters(accounts[0]);//생성된 유권자 매핑을 읽을 것임
}).then(function(voted) {
assert(voted, "the voter was marked as voted");//투표 유무를 부울 값으로 보여줌
return electionInstance.candidates(candidateId);
}).then(function(candidate) {
var voteCount = candidate[2];
assert.equal(voteCount, 1, "increments the candidate's vote count");
})
});
#자바스크립트 isnan #자바스크립트 isempty #자바스크립트 isnumber #자바스크립트 isnull #자바스크립트 isarray #자바스크립트 is not defined #자바스크립트 is not a function #자바스크립트 is #자바스크립트 isinteger #자바스크립트 isnumeric